Results 1 to 15 of 15

Thread: [SOLVED] Run-time error '1004': Select method of Range class failed

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2006
    Posts
    8

    [SOLVED] Run-time error '1004': Select method of Range class failed

    Hi everyone, first time poster (as many people who are at their wit's end are, I'm sure) here. I did a search for the problem I'm having, but from the posts I found, it's kind of a vague problem, so I didn't really find a solution to what I'm having problems with. I'll give a quick rundown of what I'm trying to do, then a quick rundown of the code, then, uh, the floor is yours.

    Basically, I've got a workbook with three sheets in it. One of the sheets has a lot of stuff that is dependant on information put into another sheet. For example, customer name, different quantities ordered, measurements, etc. The second sheet does calculations on that, and makes a "customer info"/"work order" type sheet. My task is to create a "Save" button that takes the second sheet, copies it into a new workbook, and saves it as one of the field names. It needs to be just the data/formatting copied over, and JUST that one sheet.

    I'm also to have the original file (the one that has the Save button) clear the first sheet, where the data gets entered, not calculated.



    So. Here's my entire code for the Save button. It's probably horribly sloppy and completely inefficient, but hey, that's why I'm posting here, right?

    VB Code:
    1. Private Sub cmdSave_Click()
    2.  
    3.     Dim SavePath As String
    4.     Dim SaveFile As String
    5.  
    6.     Range("A1:G47").Select
    7.     Selection.Copy
    8.     Sheets("Customer").Activate
    9.     Workbooks.Add
    10.     Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    11.         :=False, Transpose:=False
    12.     Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
    13.         SkipBlanks:=False, Transpose:=False
    14.     Columns("A:G").EntireColumn.AutoFit
    15.     Sheets(Array("Sheet2", "Sheet3")).Select
    16.     Sheets("Sheet3").Activate
    17.     Application.CutCopyMode = False
    18.     ActiveWindow.SelectedSheets.Delete
    19.     Sheets("Sheet1").Select
    20.     Sheets("Sheet1").Name = "Procedures"
    21.     SavePath = "N:\Procedures\Customer Info\"
    22.     SaveFile = Range("G1")
    23.     ActiveWorkbook.SaveAs (SavePath & SaveFile & ".xls")
    24.     ActiveWindow.Close
    25.     [b]Range( _
    26.         "B1,G1,B2,B3,G3,B5,B6,B7,B8,I5,I6,I7,I8,I9,G13,G15,G17,G19,B13,B14,B15,B16,B19,B20,B21" _
    27.         ).Select[/b]
    28.     Range("B21").Activate
    29.     Selection.ClearContents
    30. End Sub

    The problem appears with the bolded line. I'm not sure why, as when I created a macro, and ran through this step by step, that's what I got.

    HELP ME!!!!!!!!!!

    (Please.)
    Last edited by Capo; Aug 9th, 2006 at 10:22 AM. Reason: Problem solved! :D

Posting Permissions

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



Click Here to Expand Forum to Full Width