+ Reply to Thread
Results 1 to 3 of 3

Method ‘Range’ of object ‘_Global’ failed

  1. #1
    Registered User
    Join Date
    12-18-2006
    Posts
    36

    Method ‘Range’ of object ‘_Global’ failed

    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 

  2. #2
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628
    I am not sure but I think you have to put the row:

    Range("B" & thisrow & "").Select

    before the 'end if' row.

    Regards,
    Antonio

  3. #3
    Registered User
    Join Date
    12-18-2006
    Posts
    36
    Hey thanks antoka05

    Worked a treat.....

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1