Hi all!
I'm currently using the below code (truncated) for another process, and I want to alter it to include one more search criteria.
The below code is searching for an open workbook and doing a copy/paste into a specific tab. What I'm looking to do now, is in addition to searching for the open workbook, also search for a specific TAB of the workbook and copy/paste data.
Tab Name Location (what the code needs to search for)
Workbook: SLMR Master
Tab: Main
Cell: B1
Could someone help me alter the below code to have it also search for the correct tab?
thanks so much all!
I'm currently using the below code (truncated) for another process, and I want to alter it to include one more search criteria.
The below code is searching for an open workbook and doing a copy/paste into a specific tab. What I'm looking to do now, is in addition to searching for the open workbook, also search for a specific TAB of the workbook and copy/paste data.
Tab Name Location (what the code needs to search for)
Workbook: SLMR Master
Tab: Main
Cell: B1
Could someone help me alter the below code to have it also search for the correct tab?
thanks so much all!
VBA Code:
S
Sub Monthly_CP()
'
Dim LoopCounter As Long
Dim wb1 As Workbook
Dim fm
On Error GoTo skip:
With Workbooks("SLMR Master - All Regions").Sheets("Main")
Set wb1 = Workbooks("Service Level Miss " & .Range("k2") & " MTD " & .Range("e2"))
'
fm = Application.Match(.Range("E14"), wb1.Sheets("MTD performance").Range("A4:A40"), 0)
If IsNumeric(fm) Then wb1.Sheets("MTD Performance").Range("B" & fm + 3 & ":C" & fm + 3).Value = .Range("F14:G14").Value
End With
Exit Sub
skip:
If Err.Number = 9 Then
MsgBox "No matching SLM Market Workbook found. Please ensure the correct workbook is open and try again. If correct, please refer to the troubleshooting guide on the instructions tab."
Else
MsgBox Err.Description
End If
End Sub