First off thanks for the help
I'm trying to use a variable for the VLOOKUP value. The below code works however it adds parenthesis around the VLOOKUP value, the result is it's not being recognized as a cell location. I have tried changing the variable types but have not had any luck.
This is an example of what gets put into the cell
"=VLOOKUP('a4','prod a'!$A$1:$C$800,2,FALSE)"
Need help in removing the parenthesis around the lookup value
Below is the code,
Dim i As Integer
Dim name As String
'User will select column to update via input box
Select Case ActiveCell.Value
Case "PROD A"
ActiveCell.Offset(1, 0).range("a1").Select
FinalRow = Cells(ROWs.count, 1).End(xlUp).row
For i = 2 To FinalRow
' to check that i changes (checked out and then commented out)
' MsgBox i
' add i to column A to get cell location for vlookup
name = "a" & i
' to check that cell location is correct (checked and commented out)
' MsgBox name
' two methods of naming vlookup value both result in parenthesis being added
ActiveCell.FormulaR1C1 = "=VLOOKUP(" & name & " ,'prod a'!R1C1:R800C3,2,FALSE)"
' ActiveCell.FormulaR1C1 = "=VLOOKUP(" & "a" & i & ",'prod a'!R1C1:R800C3,2,FALSE)"
ActiveCell.Offset(1, 0).range("A1").Select
Next i
' Case "PROD 20" Same code as above
' Case "PROD 21" ""
' Case "PROD 21" ""
' Case "PROD 21" ""
End Select
Thanks again
I'm trying to use a variable for the VLOOKUP value. The below code works however it adds parenthesis around the VLOOKUP value, the result is it's not being recognized as a cell location. I have tried changing the variable types but have not had any luck.
This is an example of what gets put into the cell
"=VLOOKUP('a4','prod a'!$A$1:$C$800,2,FALSE)"
Need help in removing the parenthesis around the lookup value
Below is the code,
Dim i As Integer
Dim name As String
'User will select column to update via input box
Select Case ActiveCell.Value
Case "PROD A"
ActiveCell.Offset(1, 0).range("a1").Select
FinalRow = Cells(ROWs.count, 1).End(xlUp).row
For i = 2 To FinalRow
' to check that i changes (checked out and then commented out)
' MsgBox i
' add i to column A to get cell location for vlookup
name = "a" & i
' to check that cell location is correct (checked and commented out)
' MsgBox name
' two methods of naming vlookup value both result in parenthesis being added
ActiveCell.FormulaR1C1 = "=VLOOKUP(" & name & " ,'prod a'!R1C1:R800C3,2,FALSE)"
' ActiveCell.FormulaR1C1 = "=VLOOKUP(" & "a" & i & ",'prod a'!R1C1:R800C3,2,FALSE)"
ActiveCell.Offset(1, 0).range("A1").Select
Next i
' Case "PROD 20" Same code as above
' Case "PROD 21" ""
' Case "PROD 21" ""
' Case "PROD 21" ""
End Select
Thanks again