Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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


--
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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default 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" wrote in message
news:steven_thomas.21uhnm_1137612301.669@excelforu m-nospam.com...

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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error 1004: Calculate Method of Range Class Failed Dan Winterton[_2_] Excel Programming 6 October 13th 05 10:19 PM
Excel 97 error: 'Copy method of range class failed' Linking to specific cells in pivot table Excel Programming 10 July 9th 05 03:19 AM
Unable to set the NumberFormat Property of the Range Class - ERROR Jon Delano Excel Programming 3 November 10th 04 07:33 PM
Error using Auto Fill of the class range Leonardo Koblitz Excel Programming 2 March 3rd 04 05:56 PM
unable to set formulaarray of range class ERROR when using Conditional Sum John H.[_2_] Excel Programming 1 September 25th 03 09:55 PM


All times are GMT +1. The time now is 10:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"