View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Ayo Ayo is offline
external usenet poster
 
Posts: 489
Default Unable to get the VLookup property of the WorksheetFunction cl

this is my extire code:
Private Sub cmdUpdate_Click()
Dim insiteWS As Worksheet, trueOnAirWS As Worksheet, sStatusWS As Worksheet
Dim rngInsitedata As Range, rngsStatusdata As Range, c As Range
Dim reportCurrentRow As Integer
Dim insitelastRow As Integer, trueOnAirlastRow As Integer, sStatuslastRow
As Integer
Application.Calculation = xlCalculationManual

Set sStatusWS = Worksheets("Starting Status 9-29-2009")
sStatuslastRow = sStatusWS.Range("A65536").End(xlUp).Row
Set rngsStatusdata = sStatusWS.Range("$C$2:$I$" & sStatuslastRow & "")

Set insiteWS = Worksheets("InSite Milestones")
insitelastRow = insiteWS.Range("A65536").End(xlUp).Row
Set rngInsitedata = insiteWS.Range("A2:A" & insitelastRow & "")

Set trueOnAirWS = Worksheets("True On Air Status")
trueOnAirlastRow = trueOnAirWS.Range("A65536").End(xlUp).Row
trueOnAirWS.Range("A2:I" & trueOnAirlastRow).ClearContents

reportCurrentRow = 2
For Each c In rngInsitedata.Cells
If c.Offset(0, 5) = "Actual" And c.Offset(0, 7).Value < "Actual" Then
trueOnAirWS.Range("A" & reportCurrentRow & "") = c.Value
trueOnAirWS.Range("B" & reportCurrentRow & "") = c.Offset(0,
1).Value
trueOnAirWS.Range("C" & reportCurrentRow & "") = c.Offset(0,
2).Value
trueOnAirWS.Range("D" & reportCurrentRow & "") = c.Offset(0,
3).Value
trueOnAirWS.Range("E" & reportCurrentRow & "") = c.Offset(0,
4).Value
trueOnAirWS.Range("F" & reportCurrentRow & "") = c.Offset(0,
5).Value
trueOnAirWS.Range("G" & reportCurrentRow & "") = c.Offset(0,
6).Value
trueOnAirWS.Range("H" & reportCurrentRow & "") = c.Offset(0,
7).Value

If WorksheetFunction.CountIf(Column1, c.Offset(0, 2).Value) 0
Then
trueOnAirWS.Range("J" & reportCurrentRow & "") =
WorksheetFunction.VLookup(c.Offset(0, 2).Value, rngsStatusdata, 7, False)
End If
reportCurrentRow = reportCurrentRow + 1
End If
Next c

trueOnAirlastRow = trueOnAirWS.Range("A65536").End(xlUp).Row
For Each c In trueOnAirWS.Range("J2:J" & trueOnAirlastRow).Cells
If c.Value = "AFTER 9/30" Then
c.Offset(0, -1) = c.Value
End If
Next c
Application.Calculation = xlCalculationAutomatic
Exit Sub

End Sub
"Gary''s Student" wrote:

Probably related to the inputs you are supplying and how they are Dim'ed:

Sub servient()
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''
Dim c As Range, rngsStatusdata As Range
Set c = Range("A1")
c.Offset(o, 2).Value = 2
Set rngsStatusdata = Range("A1:Z100")
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''
If Application.WorksheetFunction.VLookup(c.Offset(0, 2).Value,
rngsStatusdata, 7, False) < " " Then
MsgBox ("true")
Else
MsgBox ("false")
End If
End Sub

works just fine.
--
Gary''s Student - gsnu200905


"Ayo" wrote:

How do I go around this runtime error? I tried the following:

If Application.WorksheetFunction.VLookup(c.Offset(0, 2).Value,
rngsStatusdata, 7, False) < " " Then

If Application.WorksheetFunction.VLookup(c.Offset(0, 2).Value,
rngsStatusdata, 7, False) < "#N/A" Then

If Application.WorksheetFunction.VLookup(c.Offset(0, 2).Value,
rngsStatusdata, 7, False) < "#N/A" Then
trueOnAirWS.Range("J" & reportCurrentRow & "") =
Application.WorksheetFunction.VLookup(c.Offset(0, 2).Value, rngsStatusdata,
7, False)
End If