Demonsguile
New Member
- Joined
- Oct 13, 2011
- Messages
- 39
The workbook I'm working on has several sheets: Totals, Monday, Tuesday, etc set into a SheetArray.
The problem is that I'm trying to perform a VLOOKUP on data in worksheet "Monday" against column A in worksheet "Totals". However, the size of column A will change as the codes iterates through the days. Therefore, I need the range of column A in the Totals worksheet to be dynamic.
During this process, the code should only find 1 error in ValidProject. But, each are throwing errors. I think it's because the VLOOKUP isn't searching through the correct range, but I don't know how to check it.
The problem is that I'm trying to perform a VLOOKUP on data in worksheet "Monday" against column A in worksheet "Totals". However, the size of column A will change as the codes iterates through the days. Therefore, I need the range of column A in the Totals worksheet to be dynamic.
Code:
'Find any new projects in the daily data that are not in the Totals.
DayProjCount = Range(Sheets(SheetArray(A)).Range("AA2"), Sheets(SheetArray(A)).Range("AA2").End(xlDown)).Cells.Count
ProjCell = 2
With Worksheets("Totals")
Set rng = .Range("a2", .Range("a2").End(xlDown))
End With
For c = 1 To DayProjCount
On Error Resume Next
With Worksheets(SheetArray(A))
ValidProject = Application.VLookup(Cells(ProjCell, 27), rng, 1, False)
'MsgBox (ValidProject)
If IsError(ValidProject) Then
MsgBox ("Error Found")
Else: MsgBox ("No Error")
End If
ProjCell = ProjCell + 1
End With
Next c