Results 1 to 3 of 3

Thread: Run time error:'1004': Method 'Range' of object '_Global' failed

  1. #1
    Join Date
    Feb 2006
    Posts
    99

    Run time error:'1004': Method 'Range' of object '_Global' failed

    I have a problem.
    The error in subject appear when i run the macro
    Can u tell me why. It has runtime error message like this: Method 'Range' of object '_Global' failed." ... why is that? Did I missed out something important?

    Code:
    Case "CENTRALIZATOR SURVEY" 
                    Dim SHT As Object 
                    Set SHT = Application.ThisWorkbook.Sheets("CENTRALIZATOR SURVEY") 
                    SHT.Cells(10, 1) = UCase(n) 
                    If IsEmpty(SHT.Cells(11, 1)) = False Then 
                    Do 
                        Range(SHT.Cells(11, 1), Cells(11, 8)).Select 
                        Selection.EntireRow.Delete 
                        Set SHT = Nothing 
                    Loop Until IsEmpty(SHT.Cells(11, 1)) 
                End If 
                    nr_crt = 0 
                    suma = 0 
                    For i = 5 To 184 
                        For j = 3 To 6 
                            Select Case ThisWorkbook.Sheets("RAPORT ZILNIC").Cells(i, j).Value 
                                Case "SURVEY S1" 
                                    Set SHT = Application.ThisWorkbook.Sheets("CENTRALIZATOR SURVEY") 
                                    nr_crt = nr_crt + 1 
                                    suma = suma + 5 
                                    For k = 10 To 10 + nr_crt 
                                        If ThisWorkbook.Sheets("RAPORT ZILNIC").Cells(1, 3).Value = ThisWorkbook.Sheets("CENTRALIZATOR SURVEY").Cells(k, 1).Value Then 
                                            Range(SHT.Cells(k + nr_crt, 1), Cells(k + nr_crt, 8)).Select 
                                            Selection.EntireRow.Copy 
                                            Selection.Insert 
                                            Application.CutCopyMode = False 
                                            SHT.Cells(k + nr_crt, 1).Value = nr_crt 
                                            SHT.Cells(k + nr_crt, 2).Value = ThisWorkbook.Sheets("RAPORT ZILNIC").Cells(i, j + 1).Value 
                                            SHT.Cells(k + nr_crt, 3).Value = ThisWorkbook.Sheets("RAPORT ZILNIC").Cells(i, j + 2).Value 
                                            SHT.Cells(k + nr_crt, 4).Value = ThisWorkbook.Sheets("RAPORT ZILNIC").Cells(i, j + 3).Value 
                                            SHT.Cells(k + nr_crt, 5).Value = "S1" 
                                        End If 
      
                                    Next k 
                                    Set SHT = Nothing 
                                Case "SURVEY S2" 
                                    Set SHT = Application.ThisWorkbook.Sheets("CENTRALIZATOR SURVEY") 
                                    nr_crt = nr_crt + 1 
                                    suma = suma + 40 
                                    For k = 10 To 10 + nr_crt 
                                        If ThisWorkbook.Sheets("RAPORT ZILNIC").Cells(1, 3).Value = SHT.Cells(k, 1).Value Then 
                                            Range(SHT.Cells(k + nr_crt, 1), Cells(k + nr_crt, 8)).Select 
                                            Selection.EntireRow.Copy 
                                            Selection.Insert 
                                            Application.CutCopyMode = False 
                                            SHT.Cells(k + nr_crt, 1).Value = nr_crt 
                                            SHT.Cells(k + nr_crt, 2).Value = ThisWorkbook.Sheets("RAPORT ZILNIC").Cells(i, j + 1).Value 
                                            SHT.Cells(k + nr_crt, 3).Value = ThisWorkbook.Sheets("RAPORT ZILNIC").Cells(i, j + 2).Value 
                                            SHT.Cells(k + nr_crt, 4).Value = ThisWorkbook.Sheets("RAPORT ZILNIC").Cells(i, j + 3).Value 
                                            SHT.Cells(k + nr_crt, 5).Value = "S2" 
                                        End If 
      
                                    Next k 
                                    Set SHT = Nothing 
                                Case "ALTE SERVICII" 
                                    Set SHT = Application.ThisWorkbook.Sheets("CENTRALIZATOR SURVEY") 
                                    nr_crt = nr_crt + 1 
                                    suma = suma + 10 
                                    For k = 10 To 10 + nr_crt 
                                        If ThisWorkbook.Sheets("RAPORT ZILNIC").Cells(1, 3).Value = SHT.Cells(k, 1).Value Then 
                                            Range(SHT.Cells(k + nr_crt, 1), Cells(k + nr_crt, 8)).Select 
                                            Selection.EntireRow.Copy 
                                            Selection.Insert 
                                            Application.CutCopyMode = False 
                                            SHT.Cells(k + nr_crt, 1).Value = nr_crt 
                                            SHT.Cells(k + nr_crt, 2).Value = ThisWorkbook.Sheets("RAPORT ZILNIC").Cells(i, j + 1).Value 
                                            SHT.Cells(k + nr_crt, 3).Value = ThisWorkbook.Sheets("RAPORT ZILNIC").Cells(i, j + 2).Value 
                                            SHT.Cells(k + nr_crt, 4).Value = ThisWorkbook.Sheets("RAPORT ZILNIC").Cells(i, j + 3).Value 
                                            SHT.Cells(k + nr_crt, 5).Value = "A" 
                                        End If 
      
                                    Next k 
                                    Set SHT = Nothing 
                                Case "RECUPERARE" 
                                    Set SHT = Application.ThisWorkbook.Sheets("CENTRALIZATOR SURVEY") 
                                    nr_crt = nr_crt + 1 
                                    suma = suma + 20 
                                    For k = 10 To 10 + nr_crt 
                                        If ThisWorkbook.Sheets("RAPORT ZILNIC").Cells(1, 3).Value = SHT.Cells(k, 1).Value Then 
                                            Range(SHT.Cells(k + nr_crt, 1), Cells(k + nr_crt, 8)).Select 
                                            Selection.EntireRow.Copy 
                                            Selection.Insert 
                                            Application.CutCopyMode = False 
                                            SHT.Cells(k + nr_crt, 1).Value = nr_crt 
                                            SHT.Cells(k + nr_crt, 2).Value = ThisWorkbook.Sheets("RAPORT ZILNIC").Cells(i, j + 1).Value 
                                            SHT.Cells(k + nr_crt, 3).Value = ThisWorkbook.Sheets("RAPORT ZILNIC").Cells(i, j + 2).Value 
                                            SHT.Cells(k + nr_crt, 4).Value = ThisWorkbook.Sheets("RAPORT ZILNIC").Cells(i, j + 3).Value 
                                            SHT.Cells(k + nr_crt, 5).Value = "D" 
      
                                        End If 
      
                                    Next k 
                                    Set SHT = Nothing 
                            End Select 
                    Set SHT = Application.ThisWorkbook.Sheets("CENTRALIZATOR SURVEY") 
                    SHT.Cells(nr_crt + 13, 6).Value = suma 
                    Set SHT = Nothing 
                    Next j 
                    Next i

  2. #2
    Join Date
    Jun 2006
    Posts
    623
    The only thing I can tell you is to put a break point on the loop and watch what it's doing. Track your recordset and your counter variables. Also try doing a Cntrl + Alt+ Del and looking in the running processes to see if Excel.exe is already running. It may not be closing properly after the first run. Have you tried clicking the button again WHILE the first run's excel is still displayed? If so, what does it do?

  3. #3
    Join Date
    Dec 2007
    Posts
    1,599
    Is the workbook cnt.xls open when you try this?

Similar Threads

  1. Replies: 1
    Last Post: 14-03-2012, 01:08 PM
  2. Replies: 6
    Last Post: 06-06-2011, 01:34 AM
  3. Excel VBA error: Method Add of ChartObjects failed
    By Trader_Joe in forum Software Development
    Replies: 2
    Last Post: 22-11-2010, 05:08 PM
  4. Error ASP 0177: 8000401A Server object creation failed
    By joel84 in forum Software Development
    Replies: 2
    Last Post: 12-05-2009, 10:32 PM
  5. ICQ 6 Error: Failed to init application object. Code (3)
    By Simpson in forum Technology & Internet
    Replies: 4
    Last Post: 05-02-2009, 05:14 PM

Tags for this Thread

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
  •  
Page generated in 1,714,037,626.88769 seconds with 17 queries