Darren Smith
Well-known Member
- Joined
- Nov 23, 2020
- Messages
- 631
- Office Version
- 2019
- Platform
- Windows
I am trying to return the row number but it says Run-Time error 91 on the line below...
Any ideas why???
Any ideas why???
VBA Code:
iRow = .Range("S13:S" & .UsedRange.Rows.Count).Find("GROSS PROFIT ANALYSIS", LookIn:=xlValues, lookat:=xlWhole).Row
Private Sub Fill_Details_to_JobRecord_Click()
TurnOff
Application.ScreenUpdating = False
Dim SrcOpen As Workbook
Dim Des As Workbook
Dim JCM As Worksheet
Dim TGSR As Worksheet
Dim FilePath As String
Dim Filename As String
Dim DesDataRange As Range
Dim SrcDataRange As Range
Dim iRow As Integer
FilePath = "\\tgs-srv01\share\ShopFloor\PRODUCTION\JOB BOOK\"
Filename = "JOB RECORD SHEET.xlsm"
Set JCM = ThisWorkbook.Worksheets("Job Card Master")
Set SrcDataRange = JCM.Range("A13").CurrentRegion
' On Error GoTo ErrHandler
With JCM
iRow = .Range("S13:S" & .UsedRange.Rows.Count).Find("GROSS PROFIT ANALYSIS", LookIn:=xlValues, lookat:=xlWhole).Row
iRow = iRow + 7
End With
Set SrcOpen = Workbooks.Open(FilePath & Filename)
Set TGSR = SrcOpen.Worksheets("TGS JOB RECORD")
Windows("JOB RECORD SHEET.xlsm").Visible = True
TGSR.Range("V").Value = WorksheetFunction.VLookup(JCM.Range("G2"), iRow, 22, 0)
Range("V").Select
SrcOpen.Close
'ErrHandler:
' If Err = 1004 Then
' MsgBox "Fill Job Number in Job Card Master Sheet Cell G2"
' End If
TurnOn
End Sub