ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   copying areas and macro loops (https://www.excelbanter.com/excel-programming/276844-re-copying-areas-macro-loops.html)

dynamicsoul

copying areas and macro loops
 
run start time?......



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/


dynamicsoul[_2_]

copying areas and macro loops
 
Tried that code and run macro this is what it says in VBA...

Compile Error

sub or function not defined

and it has highlighted LastRow on the code line below in blue.

Lr = LastRow(Sheets("Sheet2")) + 1



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/


dynamicsoul[_3_]

copying areas and macro loops
 
woohoo....now we are getting there...thank you for your patience.

Only one slight problem......

the data values are being copied to sheet 2 like this.......
A B
1 F21
2 F22
3 F21
4 F22
5
6

To plot my graph how I want I need the data like this in sheet 2.
A B C
1 F21 F22
2 F21 F22
3 F21 F22
4 F21 F22
5
6

I have tried messing about with code to see if it would lay out
differently but keep getting errors.

By the way I must thank you again for your help....It is very much
appreciated.....



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/


Tom Ogilvy

copying areas and macro loops
 
Sub CopyOneArea()
Dim sourceRange As Range
Dim destrange As Range
Dim Lr As Long
Lr = LastRow(Sheets("Sheet2")) + 1
Set sourceRange = Sheets("Sheet1").Range("F21:F22")
Set destrange = Sheets("Sheet2").Range("A" & Lr)
sourceRange.copy
destrange.Pastespecial Paste:=xlPasteAll, Transpose:=True
StartTimer
End Sub

--
Regards,
Tom Ogilvy


"dynamicsoul" wrote in message
...
woohoo....now we are getting there...thank you for your patience.

Only one slight problem......

the data values are being copied to sheet 2 like this.......
A B
1 F21
2 F22
3 F21
4 F22
5
6

To plot my graph how I want I need the data like this in sheet 2.
A B C
1 F21 F22
2 F21 F22
3 F21 F22
4 F21 F22
5
6

I have tried messing about with code to see if it would lay out
differently but keep getting errors.

By the way I must thank you again for your help....It is very much
appreciated.....



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/





All times are GMT +1. The time now is 02:34 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com