Method Of Range Class Failed (SOLVED)

Elemental

Board Regular
Joined
Jul 13, 2002
Messages
110
:razz:

i just figured out that when you change sheets too often in VBA and get an "Activate Method Of Range Class Failed" or a "Select Method Of Range Class Failed" etc, simply retype the sheets command before it

for example :

Sheets("Work1").Select
Range("A1:D50").Select

OR

Sheets(Work1").Range("A1:D50").Select

this code in VBA, if used too often or the mentioned sheet is not the currently selected sheet in a Sub, will cause errors, and to correct this, simply type

Sheets("Work1").Select
Sheets("Work1").Range("A1:D50").Select

this makes sure that the sheet is selected before running any other range/sheet type commands.

I hope this clears up some other ppl's problems, it had me for a few weeks.
 
Hi
Avoid using Select at all:

Code:
Sub Backup()
Dim xx As Integer
xx = Sheets("Data").Range("C1").Value
With Sheets("Data").Range("B3:P4").Offset(xx, 0).Interior
        
  .Pattern = xlSolid
        
  .PatternColorIndex = xlAutomatic
        
  .ThemeColor = xlThemeColorDark1
        
  .TintAndShade = -0.25
        
  .PatternTintAndShade = 0
    
End With
End Sub

Would avoiding Select solve this issue? I'm having the same problem but don't know how I could go about avoiding Select.
My code:
Code:
Sub CopyAppend()
    With Application
        .ScreenUpdating = False
        .EnableEvents = False
    End With
    Sheets("K2").Select
    Sheets("K2").Range("$B$16:$J$23").Select
        Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture
        
    Sheets("Append").Select
    Range("A1").Select
        Lastrow = [a65000].End(xlUp).Row 'count the last row number
        Cells(Lastrow, 1).Offset(8, 0).Select 'select cell column A and offset last row
            ActiveCell.Value = "."
            ActiveCell.Offset(-8, 0).Select
                Worksheets("Append").Pictures.Paste
        
    Sheets("Impressão das Etiquetas").Select
    Range("C5").Select
    
    With Application
        .ScreenUpdating = True
        .EnableEvents = True
    End With
    
End Sub
 
Upvote 0

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Try something like this:
Code:
Sub CopyAppend()
    With Application
        .ScreenUpdating = False
        .EnableEvents = False
    End With
    Sheets("K2").Range("$B$16:$J$23").CopyPicture Appearance:=xlScreen, Format:=xlPicture
        
    With Sheets("Append")
        Lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row 'count the last row number
        With .Cells(Lastrow, 1)
            .Offset(8, 0).Value = "."
            .PasteSpecial xlPasteAll
        End With
    End With
            
    With Application
        .ScreenUpdating = True
        .EnableEvents = True
    End With
    
End Sub
 
Upvote 0
Try something like this:
Code:
Sub CopyAppend()
    With Application
        .ScreenUpdating = False
        .EnableEvents = False
    End With
    Sheets("K2").Range("$B$16:$J$23").CopyPicture Appearance:=xlScreen, Format:=xlPicture
        
    With Sheets("Append")
        Lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row 'count the last row number
        With .Cells(Lastrow, 1)
            .Offset(8, 0).Value = "."
            .PasteSpecial xlPasteAll
        End With
    End With
            
    With Application
        .ScreenUpdating = True
        .EnableEvents = True
    End With
    
End Sub

.PasteSpecial xlPasteAll causes error. Tells me: RT error 1004 "PasteSpecial method of Range class failed"
 
Upvote 0
I am looking for a formula that searches different columns and depending on which column it matches it returns the name of the top of the column it is found in.
Example: If a specific zip code (in the labeled zip code column) matches any zip code under the contractor column (column labeled by contactor name) it should pull the contractor name and insert it into the Responsible Party Column.
Sorry if I'm not explaining this well. Please HELP!
 
Upvote 0
:razz:

i just figured out that when you change sheets too often in VBA and get an "Activate Method Of Range Class Failed" or a "Select Method Of Range Class Failed" etc, simply retype the sheets command before it

for example :

Sheets("Work1").Select
Range("A1:D50").Select

OR

Sheets(Work1").Range("A1:D50").Select

this code in VBA, if used too often or the mentioned sheet is not the currently selected sheet in a Sub, will cause errors, and to correct this, simply type

Sheets("Work1").Select
Sheets("Work1").Range("A1:D50").Select

this makes sure that the sheet is selected before running any other range/sheet type commands.

I hope this clears up some other ppl's problems, it had me for a few weeks.

Hi guys, I just wanted to write that I use ".Select" in all the macros I'm creating.. and the trick in avoiding that "Select Method Of Range Class Failed" message is pretty simple. Just make sure that in Excel, the selected Sheet is the same one you are creating your Macro for. For example Sheet1 in Excel --> Sheet1 in VBA.

Thats all. :biggrin:
 
Upvote 0
Welcome to the board.

Hi guys, I just wanted to write that I use ".Select" in all the macros I'm creating.. and the trick in avoiding that "Select Method Of Range Class Failed" message is pretty simple. ...

Yes, it is, and has been suggested several times in this thread: Don't use Select. It's unnecessary and slows your code.
 
Upvote 0
Well, in that case, you succeeded in repeating the suggestion of the original, 13-year old post. Good to know it still works, thanks.
 
Upvote 0

Forum statistics

Threads
1,224,825
Messages
6,181,190
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top