View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Die_Another_Day Die_Another_Day is offline
external usenet poster
 
Posts: 644
Default Help understanding Variables in an IF/VLOOKUP statement

You are sending a string to the target cells formula, noted by the ""
marks, Therefore VB sees the Cells(i,16) as text and not a range. Try
this instead:
"=IF(VLOOKUP(" & Cells(i,16).Address & ",ClientList,1,False)" _
& ", ""ERROR"",VLOOKUP(" & Cells(i,16).Address &
",ClientList,1,False))"

HTH

Die_Another_Day
FurRelKT wrote:
Hello, newbe here...
I need to understand why i can't use this? Inside the
[VLOOKUP(Cells(i,16)]??? What can i use there? Any help would be most
appreciated.

here is the code i have so far...

Sub fillformat ()
Dim FinalRow As Long
FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To FinalRow
If Cells(i, 2).Value = "SUP" Then
Cells(i, 7).Clear
Cells(i, 7) = Left(Cells(i, 4), 5)
myvar = Cells(i, 7).Value
Cells(i, 16).Value = myvar
Cells(i, 7).Clear
Cells(i, 7).Formula =
"=IF(VLOOKUP(Cells(i,16),ClientList,1,False)" _
& ", ""ERROR"",VLOOKUP(Cells(i,16),ClientList,1,False)) "


End If
End Sub

Thank you so much.
Keri