Inputbox Value Can Be Compared To A String Variable Or A Numeric Variable At The Same Time

Dec 7, 2008

I am trying to develope a "goto" page macro where the page value maybe 1,34,7A, 256C etc. I am not clear on how an inputbox value can be compared to a string variable or a numeric variable at the same time. This is what I have done, but when the texboxvalue is "7A" it doesn't work.

View 3 Replies


ADVERTISEMENT

Append Numeric Portion Of String To Variable

Aug 18, 2007

How would I be able to assign a number portion of a variable string to another string variable. For example I have the following string:

AOSXLS_356-NewInfo

I just want the 356 assigned to a string variable.

only the first 7 characters won't change. The number part could be 2 or 4 digits, and the NewInfo portion could be anything.

View 3 Replies View Related

String Variable To Call Defined Range Variable

Nov 10, 2006

Say you define a public range variable called Inputworksheet and you set it to refer to the worksheet called Inputworksheet. You have a separate string variable with the value Inputworksheet. How do you get this string variable value to call/control the range variable Inputworksheet?

I am getting an excel worksheet value from a lookup function that corresponds to the name of a VBA range variable. Once I have this worksheet value, I would like to use the range variable that has the same name as the worksheet value.

View 5 Replies View Related

2007 Macro: Run-time Error 91:Object Variable Or With Block Variable Not Set

Feb 20, 2009

I'm fairly new to macro's and VBA, by searching on the internet i've copied and pasted some code together into a macro.
But it ends in a Run-time error 91...

The macro opens a target .xls file in a selected folder, performs copy - paste actions from masterfile to targetfile.
Than it filters data in the targetfile sheet1 and copy's the results to the various other sheets; saves and closes the targetfile.
The next target file in the folder is opened and the actions are repeated in this second target file.
For the first target file this works smoothly; but for the second one (of a total of around 100) it does not copy the filter results to the other sheets in this workbook.
The error message i get is: "Run-time error 91:Object variable or with block variable not set."
When i hit debug it highlights the line "ActiveSheet.Next.Select" which, at least in the first file, seems ok.

View 9 Replies View Related

Run Time Error 91 Object Variable Or With Block Variable Not Set

Oct 7, 2009

I am having a lot of trouble finding out why I am getting error. I believe the error is because it can't find the number. In cells C115:C314 i have the numbers 1 to 200 in order. when someone types in 1 to 9 in the text box it works, but on 10 and over i get the error ???? here is the code I have

shCalculator.Range("C115:C314").Select
Selection.Find(what:=CInt(txtPackageID), After:=ActiveCell, LookIn:=xlValues, LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False).Select
x = ActiveCell.Row
shCalculator.Range("ProposedMeter").Value = Cells(x, 7).Value
shCalculator.Range("Package").Value = Cells(x, 12).Value
shCalculator.Range("ProposedMeterAmount").Value = Cells(x, 30).Value
shCalculator.Range("Term").Value = Cells(x, 62).Value
shCalculator.Range("Discount").Value = Cells(x, 67).Value
shCalculator.Range("Equipment").Value = Cells(x, 72).Value

View 3 Replies View Related

Run Time Error 91, Object Variable Or With Block Variable Not Set

Jan 14, 2007

Function Find_Range(Find_Item As Variant, _
Search_Range As Range, _
Optional LookIn As Variant, _
Optional LookAt As Variant, _
Optional MatchCase As Boolean) As Range
Dim c As Range
If IsMissing(LookIn) Then LookIn = xlValues 'xlFormulas
If IsMissing(LookAt) Then LookAt = xlPart 'xlWhole
If IsMissing(MatchCase) Then MatchCase = False
With Search_Range
Set c = .Find( _
What:=Find_Item, _
LookIn:=LookIn, _
LookAt:=LookAt, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=MatchCase, _ ........................

Using the message box I see that sheet 1 opens but then I receive an error message Run Time Error 91, Object Variable or With Block Variable not set. I tried declaring and using set on "project" but got nowhere. I also need to have a message indicating project not found. Once this part is solved I will loop all of my other workbooks

View 5 Replies View Related

Manipulating InputBox Variable

Oct 20, 2009

I have two inputboxes. I want to set the default value of the second inputbox as (effectively) one cell down from the first inputbox entry. In other words, if I type G17 into the first inputbox, I want the second inputbox to then have a default value of G18.

View 5 Replies View Related

Variable Based On Inputbox

Mar 3, 2008

I have a macro that is designed to use an inputbox to ask for a number string that represents an entry on the current page, then go to that entry on the current page, and then select various info from that row and then use a portion of that string to move to another sheet which has the name equal to that portion of the string to perform more actions. My current problem is that when I try to set a variable based on a portion of the text input into the inputbox entry it gives me: runtime error 1004: method range of object _gloabal failed. And the line it errors on is the variable definition which is based on a portion of the inputbox entry.

Dim MyInput As String
Dim ChooseDate As String
Dim Hours As String
Dim SR As Integer
Dim ER As Integer
Dim SC As Integer
Dim EC As Integer
Dim RowVar As Integer
Dim ColVar As Integer
Dim found As Boolean
MyInput = InputBox(" Date-Time Number?")
If MyInput = vbNullString Then Exit Sub
ChooseDate = (Mid(Range(MyInput), 1, 4))

The "choosedate=" line is where it errors. It's suppose to take, as a string, the first four characters of the text input into the inputbox. Then it searches the current sheet for the entire entry, selects it, uses that row to collect more info and then moves to the sheet in the workbook that has the name equal to the first four digits of the inputbox text to do more actions. I'm sure it's a syntax error but my knowledge is at it's limits.

View 7 Replies View Related

Numeric Variable For Sheet Name

Jan 8, 2007

I have a workbook with a lot of sheets. The names of these sheets are numbers ranging from 000001 to 999999, and are listed in column A in the Sheet TOTAL. Moreover these numbers (and the appropriate sheets) built 9 groups out of which every group has its own individual Tab color, also used in the A column of the TOTAL Sheet to differentiate between these groups. Now I want the following code to get data from each of the sheet belonging to a certain group and paste it to one of the 9 extra sheets (SH1, SH2, SH3... SH9) basing on the color of the sheet. The specified rng range is in the Sheet TOTAL (the names of all of the sheets are stored there).

Sub allinone()
Dim rng, c As Range
Set rng = Range([a2], [a2].End(xlDown))
For Each c In rng
If c.Interior.ColorIndex = 4 And c > 0 Then
Worksheets(c.Value).Range("a2:db2").Copy
Worksheets("SH1").Range("A65535").End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _...................

View 2 Replies View Related

Add Leading Zeros To Variable Numeric Column

Jun 18, 2009

I have a column of about 13,000 10 digit numbers. I need to add four zero to the beginning of each row of numbers so I can make it 14 digit numbers. Is there a way to do this without cutting and pasting four zero's for each row of numbers.

View 10 Replies View Related

Insert String And String Variable Into Cell

Feb 18, 2014

I'm using a userform to create a new sheet. The form already creates the sheet and names it what was typed into the userform. Now I want it to place that variable in a cell along with a string. the following code will place the variable from the form (tbname) into cell b5.

View 2 Replies View Related

Set Variable: Object Variable Or With Block Variable Not Set

Jun 4, 2007

I have the following code (just pasting the relevant section) which crashes when it reaches the highlighted line of code. and a dialog box pops up with the text: "Object variable or With block variable not set"

Sub test()
Dim StartRng As Range
Dim Buffer As Range

Set StartRng = WorkSheets("Sheet1"),Cells(1,1)

StartRng.Activate
ActiveCell. CurrentRegion.Select

Buffer = rngStart.CurrentRegion.Copy

' I also tried the following line of code but that didn't work either
'Set Buffer = rngStart.CurrentRegion.Copy
..
...
End Sub

View 9 Replies View Related

Indicate That A Variable Is String

Oct 30, 2008

I understand that a everything is already considered to be string, but how would I phrase this?

If txtBolow = (a statement which indicates the textbox is full) Then

txtBolow. SetFocus
txtBolow. SelStart = 0
txtBolow. selLenght = Len(txtBolow)

If txLowl = ("") Then
txtLowl. SetFocus
txtLowl. SelStart = 0
txtLowl. selLenght = Len(txtBolow)

What would I use to indicate that the user has completed the data in the textboxes, and the old data is highlighted to make way for the new?

View 9 Replies View Related

Using A String Variable For Sheet Name

Aug 13, 2009

I am trying to use a variable for the name in the Sheets command so that I can put in the names of the CSV file that I have captured in a variable. Here is the macro that I recorded using Excel 2007:

View 4 Replies View Related

Get Set Of Chars From A String To A Variable

Dec 24, 2009

I believe I should use the INSTR function, but I simply dont understand its use very well. I have a string in a cell, "MEAS/SPHERE,F(QUA_1),5", the characters I need start at the "(" and end at the closing ")", ref: (QUA_1). The start and end will always be the same, the length of characters and the spelling of characters be anything. Thus, QUA_1 can be CAL_1, CAL_2, SOMEOTHERTEXT_1 or 187bgo_199, etc, always enclosed in "( )". I wish to place the characters and the closing "( )" into a variable as a string.

View 5 Replies View Related

How To Get Set Of Chars From A String To A Variable ..

Jan 8, 2010

CALIB/SENS,S(S5a90b-90),FA(CAL_15)

This one has two sets of quotes, with the information from the noted post I can retrieve the string "S5a09b-90", now that I have a double set of brackets "( )" how do I get the value for the second set of brackets, "CAL_15"?

In the quoted string, CALIB/SENS,S, is constant. The first set of brackets are constant (string length is not), the second set of brackets are constant (string length is not).

View 7 Replies View Related

Parsing A String Variable

Dec 8, 2006

It's been a long time, but I use to parse a string in C.
How do you strip off the long directory path of a string to just the filename and extension?

String Example:
S:2006 jobs602f EID Bass Lake Recycle BPSConstructionSubmittal Review16940-Instrumentation602f-16940-01.rev.doc

Wanted result:
0602f-16940-01.rev.doc

View 9 Replies View Related

Use String-Variable In Formula

Sep 16, 2009

if it is possible, to use a string variable in a Formula via VBA.

For example: ActiveCell.Formula = "=SUM(Sheet3!strVariable)"

Of course the code is not working that way. The Variable has the following structer: CellAdress;CellAdress;CellAdress... so it would perfectly fit into the formula-syntax.

Is there any possible way to do that? The reason behind it is, that I have to deal with a flexible range and I want to process this range with a formula. Actually the range is flexible, because of different filters and I only wanna count all numbers in the unhidden rows.

My varibale would then contain all celladresses, for the visible cells.

So in a nutshell: is it possible to somehow use a varible in a formula?

View 9 Replies View Related

Set A Workbook Variable As A String

Oct 20, 2009

I have a string variable contacting a file.

I want to set a workbook variable to this file, WITHOUT actually opening it!

ie:
DIM wb as Workbook
DIM filenm as String

filenm = "C: empdata.xls"
set workbook = filenm
============================================

So I know this won't work, but is there anyway around it? (bearing in mind I don't want to open the file!

View 9 Replies View Related

Using A String Variable In Formula

Apr 21, 2006

Just a quick question, is it possible to use a string variable in a Excel formula (in VBA)? Im trying to do the following in VBA

mortgageSchedName = acName & " Schedule"
Range("B6").FormulaR1C1 = "=mortgageSchedName!RC[254])"

the above results in an error because there is no such sheet as "mortgageSchedName", but I want it to access the value of that string variable.

View 6 Replies View Related

How To Extract Variable Length String

Feb 9, 2014

i just wanna extract the date shown(last data until meet the first comma) in first column to another column.

column 1
abcde, 1234
abcd, 12345
abcdef, 123

column 2
1234
12345
123

View 3 Replies View Related

Store Cells Value As String Variable?

Aug 2, 2014

I have several words in sheet2.one word per line. every line in sheet1 should be checked and deleted if the line (colum 3 and 4) contains any of the words in sheet2. i decided to go with two for-loops, my Problem is a error in line 7 and 9 (indicated by arrows). it seems to me that ...Cells(...).Value is not allowed for strings. i already tried .Text, checked several VBA Forums but could not find a solution.

View 13 Replies View Related

Variable StrArray - How To Create A String

Oct 24, 2011

I have the following code.

Code:
ActiveSheet.Range("$A$1:$AF$" & lngRows).AutoFilter Field:=x, Criteria1:=Array("ELDU238", "ELDU239", "ELDU240", "ELDU241", "ELDU242", "ELDU243", "ELDU244", "ELDU245", "ELDU246", "ELDU247"), Operator:=xlFilterValues

The values ELDU238 - ELDU247 are values in a column beginning at A2. I want to create

"ELDU238", "ELDU239", "ELDU240", "ELDU241", "ELDU242", "ELDU243", "ELDU244", "ELDU245", "ELDU246", "ELDU247"

in a string variable strArray which will enumerate whatever values are in column A beginning at A2 and create the above. I can then have

Code:
ActiveSheet.Range("$A$1:$AF$" & lngRows).AutoFilter Field:=x, Criteria1:=Array(strArray), Operator:=xlFilterValues

Hence if the number of entries changes e.g. say I have

"ELDU238", "ELDU239", "ELDU240", "ELDU241", "ELDU242", "ELDU243", "ELDU244", "ELDU245", "ELDU246", "ELDU247", "ELDU248"

the code will still work.

View 4 Replies View Related

Changing Font Of A String Variable?

Nov 28, 2012

I'm taking some university classes and one of them is called Applications Programming and we have been using excel VBA. I have a project that I'm working on, and it's very basic. Basically we need to create a userform that has 3 option buttons, 4 check boxes, a couple labels and a couple text boxes. It's suppose to be a ice cream selection terminal. Option boxes for basic flavors of ice cream, check boxes for toppings, one text box for user input of number of scoops of ice cream and the last text box to output a reciept/overview of purchase.

So here's the question... I was wondering if there's a way to change the font of a single string variable, or change the font of a word within a string. My output to the saleBox(My receipt overview) is this:

saleBox.Text = ("Thanks you for your Purchase") & vbCrLf & vbCrLf & _
"You ordered " & numOfScoop & " scoops of " & flavorChoice & "ice cream" & vbCrLf & _ "Topped with: " & toppings & vbCrLf & vbCrLf & total

(not sure how the code is gonna look in the message but I'm sure you get the idea)

i want to be able to change the font for the flavorChoice or toppings variables. They are both strings.

Anyways, I know I can get away with basically what I have there and get full marks, but I like going above what the basics are. If it's kinda complicated.

I'm gonna attach a screenshot, more info is better than not enough right... nevermind its askin for a url!

*** I just now got the idea of putting another textbox over the area that would output the text I want to change and hide the border or something and then change the font of that text box through the properties ***

View 3 Replies View Related

Creating String Using Variable File Name?

Dec 18, 2012

I'm trying to check to see if a file exists using VBA but the routines I see use a string that has the path and then the file name. I have a fixed path C:VBtesting and the a variable file name. I'm using a file name that consists of a username & date such as cwilliams201212. I'm having problems getting the variable file name into the string.

View 1 Replies View Related

VBA - Concatenating Formula With String Variable?

Jan 16, 2013

I'm getting the generic 1004 error on the Range.FormulaR1C1 line, but I can't seem to see the problem.

Code:
Sub UpdateFormulas()
Dim stockFund As String
For i = 2 To finalRow

[Code]....

The mouse-over on the stockFund variable in that last line shows the correct cell address as the value and I checked the If statement to ensure it actually finds the number. I would guess that it would be a syntax error with that line, but it looks correct to me.

View 8 Replies View Related

VBA Partial String Extraction From Variable?

Feb 12, 2013

I have a comment that I'm putting into a variable for the purpose of obtaining the persons name.

Cell C3 (in this example) just contains their employee number, but it's comment contains...

Tech ID: 123456
Name: John Doe

The Tech ID is variable from 3 chars to 6 chars and obviously the name is size is also variable. The end result will be a variable with just the persons first and last name extracted from the comment.

Code:
Dim mycmt As String
Dim techname As String
mycmt = Sheets("tech").Cells(3, "C").Comment.Text
techname = Right(mycmt, BIG-OLE-BALL-OF-CONFUSION)
MsgBox techname

My 2nd question. This is the 3rd time in recent days that I've needed a partial string and Mid, Left, Right, Len, Find just boggles my mind.

View 6 Replies View Related

Using Variable String In Shell Command

Nov 1, 2013

I'm trying to use a variable that hold a string in Shell string command. This shell is the command to take a snap picture over a given region and store the picture to a pre determined file name

***The code do compile***

The string variable is : StringAddress = "g: estsnapasnap1.jpg"

The following shell command will work

RetVal = Shell(("C:Program Files (x86)HyperSnap 7HprSnap7.exe " & " -hidden
-snap:x3602:y155:w1432:h830 -save:jpg g: estsnapasnap1.jpg"))

This one, with the string address variable, wont work

RetVal = Shell("C:Program Files (x86)HyperSnap 7HprSnap7.exe " & " -hidden
-snap:x3602:y155:w1432:h830 -save:jpg " & StringAddress)

View 1 Replies View Related

Setting A Range Using String Variable

Jan 8, 2014

I'm having trouble setting the Range "UtilizationRange" using a variable, "CurrentRange" to store that range. I get the error "Run-Time error 1004: Method 'Range' of object'_Global' failed".The rest of my code works when I set the utilization range using the actual range for my purposes, but the problem is the range will change each month and I don't want to change it manually each time. There's a cell in the excel sheet this refers to (AG3) that holds the range value, which in this case is [N7:N75], and I would just like to return that value to the variable "CurrentRange" and set UtilizationRange equal to that.

The value is returned to CurrentRange, but it's the last line that's giving me the problem.

Sub RangeTest()Dim UtilizationRange As Range, Cell As RangeDim CurrentRange As String
CurrentRange = Range("AG3").Value MsgBox (CurrentRange)
'This returns the value [N7:N75], which is what I want
Set UtilizationRange = Range("CurrentRange")End Sub

View 1 Replies View Related

Split String Variable And Use Some In Filename

Mar 16, 2009

I have a filname called ex: "Statusreport xxyyzz.xls"

I'm only interested to put xxyyzz in a variable and reuse it for saving another workbook.

How can I use the different string functions for this. The word "Statusreport" is used for apporx 20 different workbooks.

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved