What's the difference

samberyl

New Member
Joined
Mar 29, 2009
Messages
1
an anyone tell me why the first macro works but the second macro will not work :confused::confused:

This works
Sheets("Readings").Select
Application.Goto Reference:="START_COLUMN"
ActiveCell.Offset(1, -1).Range( _
"A1,A4,A7,A10,A13,A16,A19,A22,A25,A28,A31,A34,A37,A40,A43,A46,A49,A52,A55,A58,A61,A64,A67,A70,A73,A76,A79,A82" _
).Select
Selection.Copy
Sheets("Graph").Select
Range("X149").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Range("W149").Select


This will not work

Sheets("Readings").Select
Application.Goto Reference:="START_COLUMN"
ActiveCell.Offset(1, -1).Range( _
"A1,A4,A7,A10,A13,A16,A19,A22,A25,A28,A31,A34,A37,A40,A43,A46,A49,A52,A55,A58,A61,A64,A67,A70,A73,A76,A79,A82,A85,A88,A91,A94,A97,A100,A103,A106,A109,A112,A115,A118,A121,A124,A127,A130,A133,A136,A139,A142,A145,A148,A151,A154,A157,A160,A163,A166,A169,A172,A175,A178,A256,A181,A184,A187,A190,A193,A196,A199,A202,A205,A208,A211,A214,A217,A220,A223,A226,A229,A232,A235,A238,A241,A244,A247,A250,A253,A256,A259,A262,A265,A268,A271,A274,A277,A280,A283,A286,A289,A292,A295,A298,A301,A304,A307,A310,A313,A316,A319,A322,A325,A328,A331,A334,A337,A340" _
).Select
Selection.Copy
Sheets("Graph").Select
Range("AD149").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Range("A1").Select
Sheets("Readings").Select
Application.Goto Reference:="START_COLUMN"
Application.CutCopyMode = False

Regards
Sam
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
You seem to have too many cells referenced at one time...or maybe the string is too long.

In any case, perhaps this construct will get you closer to where you want to be...and be more maintainable:

I didn't duplicate all of your posted functionality
...just the copy and paste section
Code:
Sub samberyl_test()
Dim iCtr
Dim rRng As Range
Dim rCell_1 As Range
Dim rRngNew As Range
 
Set rRng = Sheets("Readings").Range("A1:A340")
Set rCell_1 = rRng.Cells(1, 1)
Set rRngNew = rCell_1
 
For iCtr = 3 To rRng.Rows.Count Step 3
    Set rRngNew = Application.Union(rRngNew, rCell_1.Offset(RowOffset:=iCtr))
Next iCtr
 
rRngNew.Copy Destination:=Sheets("Graph").Range("AD149")
End Sub
Is that something you can work with?
 
Upvote 0

Forum statistics

Threads
1,214,583
Messages
6,120,383
Members
448,955
Latest member
BatCoder

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top