Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 11-10-2008
Member
 
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
Reply With Quote
  #2  
Old 11-10-2008
Member
 
Join Date: Jun 2006
Posts: 620
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?
Reply With Quote
  #3  
Old 11-10-2008
Member
 
Join Date: Dec 2007
Posts: 1,592
Is the workbook cnt.xls open when you try this?
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Run time error:'1004': Method 'Range' of object '_Global' failed"
Thread Thread Starter Forum Replies Last Post
Excel VBA Run-time error '1004' Paste method of Worksheet class failed PatrickW Windows Software 1 14-03-2012 01:08 PM
Getting HP AIO Device object server register class object failed message on my system Donoho Hardware Peripherals 6 06-06-2011 01:34 AM
Excel VBA error: Method Add of ChartObjects failed Trader_Joe Software Development 2 22-11-2010 05:08 PM
Error ASP 0177: 8000401A Server object creation failed joel84 Software Development 2 12-05-2009 10:32 PM
ICQ 6 Error: Failed to init application object. Code (3) Simpson Technology & Internet 4 05-02-2009 05:14 PM


All times are GMT +5.5. The time now is 11:31 PM.