+ Reply to Thread
Results 1 to 3 of 3

range class error

  1. #1
    Registered User
    Join Date
    09-26-2005
    Posts
    7

    range class error

    Help Please !!!! ... I keep getting a range class error ... the macro should activate a 2nd workbook then activate the required worksheet and then copy a range of data before pasting to the original workbook ...


    Dim number As Range
    Set number = Range("c1")


    'Hazard Risk Upload
    Workbooks("Risk Register Assessment and Control Plan Tool v16.xls").Worksheets("Data Upload").Activate
    Range("A178:A294").Select
    Selection.Copy

    Workbooks("Risk Assessment Tool Master Roll Up v1.xls").Worksheets("RAT Data Upload").Activate
    Range("a55").Select
    For counter = 1 To 240
    If counter <= number Then
    ActiveCell.Offset(0, 1).Activate
    End If
    Next

    Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=False
    Application.CutCopyMode = False

  2. #2
    Toppers
    Guest

    RE: range class error

    Steven,
    Try this. I assume you want data placed NUMBERcolumns along
    in row 55.

    HTH

    Dim number As Integer
    Dim ws1 As Worksheet, ws2 As Worksheet
    Set number = Range("c1").Value



    Set ws1 = Workbooks("Risk Register Assessment and Control Plan
    Toolv16.xls").Worksheets("Data Upload")
    Set ws2 = Workbooks("Risk Assessment Tool Master Roll
    Upv1.xls").Worksheets("RAT Data Upload")


    ws1.Range("A178:A294").Copy
    ws2.Range("a55").Offset(0, number).PasteSpecial Paste:=xlValues,
    Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=False

    Application.CutCopyMode = False


    "steven_thomas" wrote:

    >
    > Help Please !!!! ... I keep getting a range class error ... the macro
    > should activate a 2nd workbook then activate the required worksheet and
    > then copy a range of data before pasting to the original workbook ...
    >
    >
    > Dim number As Range
    > Set number = Range("c1")
    >
    >
    > 'Hazard Risk Upload
    > Workbooks("Risk Register Assessment and Control Plan Tool
    > v16.xls").Worksheets("Data Upload").Activate
    > Range("A178:A294").Select
    > Selection.Copy
    >
    > Workbooks("Risk Assessment Tool Master Roll Up
    > v1.xls").Worksheets("RAT Data Upload").Activate
    > Range("a55").Select
    > For counter = 1 To 240
    > If counter <= number Then
    > ActiveCell.Offset(0, 1).Activate
    > End If
    > Next
    >
    > Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
    > SkipBlanks:= _
    > False, Transpose:=False
    > Application.CutCopyMode = False
    >
    >
    > --
    > steven_thomas
    > ------------------------------------------------------------------------
    > steven_thomas's Profile: http://www.excelforum.com/member.php...o&userid=27568
    > View this thread: http://www.excelforum.com/showthread...hreadid=502618
    >
    >


  3. #3
    Ron de Bruin
    Guest

    Re: range class error

    Hi

    Your problem is that you offset the column and there are only 256 columns
    Do you want to offset rows ???

    ' For counter = 1 To 240
    ' If counter <= number Then
    ' ActiveCell.Offset(0, 1).Activate
    ' End If
    ' Next



    This is working

    Set number = Range("c1")
    use the cell on the activesheet do you know that

    Sub test()
    Dim number As Range
    Dim counter As Long
    Set number = Range("c1")


    'Hazard Risk Upload
    Workbooks("Risk Register Assessment and Control Plan Tool v16.xls") _
    .Worksheets("Data Upload").Range("A178:A294").Copy

    Workbooks("Risk Assessment Tool Master Roll Up v1.xls").Worksheets("RAT Data Upload").Activate
    Range("a55").Select

    Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, _
    SkipBlanks:=False, Transpose:=False

    Application.CutCopyMode = False
    End Sub


    --
    Regards Ron de Bruin
    http://www.rondebruin.nl


    "steven_thomas" <[email protected]> wrote in message
    news:[email protected]...
    >
    > Help Please !!!! ... I keep getting a range class error ... the macro
    > should activate a 2nd workbook then activate the required worksheet and
    > then copy a range of data before pasting to the original workbook ...
    >
    >
    > Dim number As Range
    > Set number = Range("c1")
    >
    >
    > 'Hazard Risk Upload
    > Workbooks("Risk Register Assessment and Control Plan Tool
    > v16.xls").Worksheets("Data Upload").Activate
    > Range("A178:A294").Select
    > Selection.Copy
    >
    > Workbooks("Risk Assessment Tool Master Roll Up
    > v1.xls").Worksheets("RAT Data Upload").Activate
    > Range("a55").Select
    > For counter = 1 To 240
    > If counter <= number Then
    > ActiveCell.Offset(0, 1).Activate
    > End If
    > Next
    >
    > Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
    > SkipBlanks:= _
    > False, Transpose:=False
    > Application.CutCopyMode = False
    >
    >
    > --
    > steven_thomas
    > ------------------------------------------------------------------------
    > steven_thomas's Profile: http://www.excelforum.com/member.php...o&userid=27568
    > View this thread: http://www.excelforum.com/showthread...hreadid=502618
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1