Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Select Method of Range Class Failed" Error 1

Status
Not open for further replies.

tcgoth

IS-IT--Management
Aug 17, 2005
54
US
I have an Excel spreadsheet that has an "Input" tab where the user enters their information, a "Results" tab that performs calculations based on that input. I want to be able to email the "Results" to a client without the "Input" information. I entered the "SaveAs" script then recorded the remainder of the script to Copy/Paste Special to enable deletion of the "Input" tab. I can't figure out why I am getting the error message "Select method of Range Class Failed"

Any help would be most apreciated.


Code:
Private Sub CommandButton1_Click()

    ActiveWorkbook.SaveAs "C:\Documents and Settings\Terry\" & ActiveSheet.Cells(9, 2) & ".XLS"
Sheets("Results").Select
    Range("A1:C37").Select
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Sheets("Input Sheet").Select
    Application.CutCopyMode = False
    ActiveWindow.SelectedSheets.Delete
    ActiveWorkbook.Save

End Sub
 
I'm not sure why but you don't really need to select. Just use the range object where you otherwise have selection. I'd do something like
Code:
dim r as range
set r = sheets("results").range("a1:c37")
r.copy
.........etc.........

Also, you say you have a tab, "Input" but you refer to sheets("Input Sheet"). That could be a problem.

_________________
Bob Rashkin
 
I'm not sure that I understand why - but your suggestions worked perfectly! Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top