Results 1 to 4 of 4
  1. #1
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Houston, Texas, USA
    Posts
    432
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Range failded (Excel 97)

    I'm using a sheet that has from a1:ac133 in cells... I get the following
    error: "Select Method of Range Class Failed."

    Any ideas

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Range failded (Excel 97)

    Do you have macros in that Workbook? That message usually refers to an error in VBA code. The message box should also contain a Debug button. Clicking on that button should show you which line of code failed. We would need to see that line and possibly all of the code in the routine it is in to be able to help.
    Legare Coleman

  3. #3
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Houston, Texas, USA
    Posts
    432
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Range failded (Excel 97)

    This is what I am trying to do (See: Sample.txt):
    Open up a user defined file. Works
    Move to a Sheet called Budget. Works
    Copy the content to memory. (Crashes)
    Select My holding Workbook.
    Select the correct page.
    Delete the content on this page
    Copy the memory to this page.
    RELEASE the memory selection.

    Let me know....



    Private Sub Process_sheet(f_name As Variant, f_count As Integer)

    Dim Page_title As String
    Dim Win_name As String
    Dim Copy_name As String

    If f_count = 2 Then
    Page_title = "Budget"
    Else
    Page_title = "Budget (" + CStr(f_count - 1) + ")"
    End If

    Application.StatusBar = "Adding: " + f_name



    Workbooks.Open Filename:=f_name, Password:="c3"
    ' Store off what windows is calling it.
    Win_name = ActiveWorkbook.Name
    ' Make it the active window
    Windows(Win_name).Activate
    Worksheets("Budget").Select
    ' Here are going to copy the contents to memory
    Range("A1:x133").Select
    Selection.Copy

    ' Worksheets("Budget").Copy
    ' Copy_name = ActiveWorkbook.Name
    Application.DisplayAlerts = False
    Windows(Win_name).Close
    Application.DisplayAlerts = True

    Windows(HoldBook).Activate
    ' ThisWorkbook.Activate
    ThisWorkbook.Sheets(Page_title).Activate
    ThisWorkbook.Sheets(Page_title).Visible = True
    ' Put in on the first cell
    Range("A1").Select

    Selection.Paste

    End Sub

  4. #4
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Range failded (Excel 97)

    The code below works for me. Since I didn't know what Holdbook was (global variable?) or how it was set, I assumed that the code was running from the Holdbook workbook. If that is not the case, then you will need to change the line where I Set oHold.

    <pre>Private Sub Process_sheet(f_name As Variant, f_count As Integer)

    Dim Page_title As String
    Dim Win_name As String
    Dim Copy_name As String
    Dim oFName As Workbook, oHold As Workbook

    Set oHold = ActiveWorkbook
    If f_count = 2 Then
    Page_title = "Budget"
    Else
    Page_title = "Budget (" + CStr(f_count - 1) + ")"
    End If

    Application.StatusBar = "Adding: " + f_name



    Set oFName = Workbooks.Open(Filename:=f_name, Password:="c3")
    oFName.Sheets("Budget").Range("A1:X133").Copy

    oHold.Sheets(Page_title).Visible = True
    oHold.Sheets(Page_title).Paste Destination:=Range("A1")
    Application.DisplayAlerts = False
    oFName.Close
    Application.StatusBar = ""
    Application.DisplayAlerts = True

    End Sub
    </pre>

    Legare Coleman

Posting Permissions

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