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.
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.
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.
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
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
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.
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.
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 _...................
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.
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.
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
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.
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).
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?
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.
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 ***
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.
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
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.
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