The blow bit of code is called from the form.
If it finds the job number on the page it works fine.
If it doesn't find the job number it gives this error.
Run-time error ‘1004’:
Method ‘Range’ of object ‘_Global’ failed
Can anyone help with why this is so or how to get around it ?
PHP Code:
Sub WorkShopJobsJAN()
With UserForms(0)
' WORKSHOP JAN ~ JUN ################################################
ActiveWorkbook.Sheets("W'Shop Jan~Jun").Activate
Dim Rng As Range
FindString = .Controls("JobNumber").Value
With ActiveSheet.Range("D8:D207")
Set Rng = .Find(What:=FindString, After:=.Cells(.Cells.Count), LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
End With
If Not Rng Is Nothing Then
thisrow = Rng.Row
Range("B" & thisrow & "").Select
.Controls("Customer").Value = Range("B" & thisrow & "")
.Controls("PONumber").Value = Range("C" & thisrow & "")
.Controls("JobNumber").Value = Range("D" & thisrow & "")
.Controls("Priority").Value = Range("E" & thisrow & "")
.Controls("WorkShopType").Value = Range("F" & thisrow & "")
.Controls("EquipmentType").Value = Range("G" & thisrow & "")
.Controls("Qty").Value = Range("H" & thisrow & "")
'.Controls("WRQ").Value = Range("I" & thisrow & "")
.Controls("SerialNumber").Value = Range("J" & thisrow & "")
.Controls("TagNumber").Value = Range("K" & thisrow & "")
.Controls("Comments").Value = Range("L" & thisrow & "")
Range("M" & thisrow & "").Select
If Len(ActiveCell.Value) > 0 Then
arr = Split(ActiveCell.Value, ",")
For I = LBound(arr) To UBound(arr)
For j = 0 To .Controls("WorkshopResources").ListCount - 1
If .Controls("WorkshopResources").List(j) = arr(I) Then .Controls("WorkshopResources").Selected(j) = True
Next j
Next I
End If
.Controls("StartDate").Value = Range("N" & thisrow & "")
.Controls("FinishDate").Value = Range("O" & thisrow & "")
End If
Range("B" & thisrow & "").Select
End With
End Sub
Bookmarks