Hello, I have this code which works perfectly if active sheet has needed search value, otherwise it's an error.
How to adapt this so it searches thru more sheets instead. Thanks
The code is in plan report workbook, looking a value from weekly plan workbook and searches withing plan report workbook, then copies offset cells back to weekly plan workbook.
How to adapt this so it searches thru more sheets instead. Thanks
The code is in plan report workbook, looking a value from weekly plan workbook and searches withing plan report workbook, then copies offset cells back to weekly plan workbook.
Code:
Sub search()Application.ScreenUpdating = False
Dim rng As Range
Dim order As String
Dim rn As Long
Dim name As String
Dim county As String
Dim part As String
Dim desc As String
Dim active As Range
Windows("Weekly Plan.xls").Activate
Set active = ActiveCell
order = ActiveCell.Text
Windows("Plan_Report.xlsm").Activate
Set rng = ActiveWorkbook.ActiveSheet.Columns("D:D").Find(what:=order, _
LookIn:=xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
rn = rng.Row
name = ActiveWorkbook.ActiveSheet.Cells(rn, 5).Value
county = ActiveWorkbook.ActiveSheet.Cells(rn, 12).Value
part = ActiveWorkbook.ActiveSheet.Cells(rn, 6).Value
desc = ActiveWorkbook.ActiveSheet.Cells(rn, 11).Value
Windows("MASTER SILO Weekly Plan 2018.xls").Activate
active.Offset(-4, 0).Value = name
active.Offset(-3, 0).Value = county
active.Offset(-2, 0).Value = desc
active.Offset(-1, 0).Value = part
Application.ScreenUpdating = False
End Sub
Last edited: