Hello,
I am getting the error "Run-Time error '91': Object variable or With block variable not set", which stops at 'visible = c.Address' in the code and I'm not sure why because I have defined both "c" and "visible". Any help is appreciated!
Sub QPerLift()
Dim LastRowUpdater As Long
Dim LastRowWkbk As Long
Dim c As Range
Dim visible As Range
If WorksheetFunction.CountA(Cells) > 0 Then
'Search for any entry, by searching backwards by Rows.
LastRowUpdater = Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
End If
If IsFileOpen("K:\Replenishment Workbook Setup.xlsm") Then
Windows("Replenishment Workbook Setup.xlsm").Activate
If WorksheetFunction.CountA(Cells) > 0 Then
'Search for any entry, by searching backwards by Rows.
LastRowWkbk = Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
End If
ActiveSheet.Range("$A$3:$CI$" & LastRowWkbk).AutoFilter Field:=2, Criteria1:="E W P"
ActiveSheet.Range("$A$3:$CI$" & LastRowWkbk).AutoFilter Field:=18
Windows("Forecast Updating Tool.xlsm").Activate
ActiveSheet.Range("$A$1:$AI$" & LastRowUpdater).AutoFilter Field:=10
Windows("Replenishment Workbook Setup.xlsm").Activate
For Each c In ActiveSheet.Range("O4", Cells(Rows.Count, 1).End(xlUp))
If c.EntireRow.Hidden = False Then
visible = c.Address
Exit Sub
End If
Next
Range(c).Select
Range(c & ":O" & LastRowWkbk).SpecialCells(xlCellTypeVisible).FormulaR1C1 = "=VLOOKUP(RC[-11],'[Forecast Updating Tool.xlsm]Sheet1'!C4:C35,4,FALSE)"
ActiveSheet.Range("$A$3:$CI$" & LastRowWkbk).AutoFilter Field:=2
Range("O4:O" & LastRowWkbk).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveSheet.Range("$A$1:$CI$" & LastRowWkbk).AutoFilter Field:=18, Criteria1:="=A", _
Operator:=xlOr, Criteria2:="=C"
Thanks,
Brad
Bookmarks