Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Recording a macro

Hello All

I need a macro that will do the following:

1) increase the selected cell range by including the 3 cells immediately
below the initially-selected cell
2) copy the selected cells (there will be four of them)
3) go to the cell that is 2 cells to the right of the initially-selected
cell
4) paste-transpose

So for e.g. with:
A1 = "Green"
A2 = "Blue"
A3 = "Red"
A4 = "Yellow"

and all other cells empty, if I start the macro with A1 selected, I want it
to result in:

C1 = "Green"
D1 = "Blue"
E1 = "Red"
F1 = "Yellow"

I have tried to do this by recording the macro, but although the
paste-transpose works fine, the cell references are always absolute -
whereas I need to make them relative (i.e. "go down 3 cells" rather than "go
to A4").

What I have so far is:

Range("A1:C4").Select
Selection.Copy
Range("E1").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=True

Hope someone can help
Many thanks
Les


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Recording a macro

When you start recording a macro the Stop Recording toolbar should appear.
The second button on that is Relative Reference. You should click that to
get something much closer to what you want.

--
Jim
"Leslie Isaacs" wrote in message
...
Hello All

I need a macro that will do the following:

1) increase the selected cell range by including the 3 cells immediately
below the initially-selected cell
2) copy the selected cells (there will be four of them)
3) go to the cell that is 2 cells to the right of the initially-selected
cell
4) paste-transpose

So for e.g. with:
A1 = "Green"
A2 = "Blue"
A3 = "Red"
A4 = "Yellow"

and all other cells empty, if I start the macro with A1 selected, I want
it to result in:

C1 = "Green"
D1 = "Blue"
E1 = "Red"
F1 = "Yellow"

I have tried to do this by recording the macro, but although the
paste-transpose works fine, the cell references are always absolute -
whereas I need to make them relative (i.e. "go down 3 cells" rather than
"go to A4").

What I have so far is:

Range("A1:C4").Select
Selection.Copy
Range("E1").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=True

Hope someone can help
Many thanks
Les



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Recording a macro

Sub CopyData()
Selection.Resize(4).Copy
Selection.Offset(0, Selection _
.Columns.Count + 1).Resize(1, 4) _
.PasteSpecial Paste:=xlPasteAll, _
Operation:=xlNone, _
SkipBlanks:=False, _
Transpose:=True
End Sub

worked for me

--
Regards,
Tom Ogilvy

"Leslie Isaacs" wrote:

Hello All

I need a macro that will do the following:

1) increase the selected cell range by including the 3 cells immediately
below the initially-selected cell
2) copy the selected cells (there will be four of them)
3) go to the cell that is 2 cells to the right of the initially-selected
cell
4) paste-transpose

So for e.g. with:
A1 = "Green"
A2 = "Blue"
A3 = "Red"
A4 = "Yellow"

and all other cells empty, if I start the macro with A1 selected, I want it
to result in:

C1 = "Green"
D1 = "Blue"
E1 = "Red"
F1 = "Yellow"

I have tried to do this by recording the macro, but although the
paste-transpose works fine, the cell references are always absolute -
whereas I need to make them relative (i.e. "go down 3 cells" rather than "go
to A4").

What I have so far is:

Range("A1:C4").Select
Selection.Copy
Range("E1").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=True

Hope someone can help
Many thanks
Les



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Recording a macro

Jim and Tom - many thanks indeed - both of your suggestions worked!
Much appreciated.
Les


"Tom Ogilvy" wrote in message
...
Sub CopyData()
Selection.Resize(4).Copy
Selection.Offset(0, Selection _
.Columns.Count + 1).Resize(1, 4) _
.PasteSpecial Paste:=xlPasteAll, _
Operation:=xlNone, _
SkipBlanks:=False, _
Transpose:=True
End Sub

worked for me

--
Regards,
Tom Ogilvy

"Leslie Isaacs" wrote:

Hello All

I need a macro that will do the following:

1) increase the selected cell range by including the 3 cells immediately
below the initially-selected cell
2) copy the selected cells (there will be four of them)
3) go to the cell that is 2 cells to the right of the initially-selected
cell
4) paste-transpose

So for e.g. with:
A1 = "Green"
A2 = "Blue"
A3 = "Red"
A4 = "Yellow"

and all other cells empty, if I start the macro with A1 selected, I want
it
to result in:

C1 = "Green"
D1 = "Blue"
E1 = "Red"
F1 = "Yellow"

I have tried to do this by recording the macro, but although the
paste-transpose works fine, the cell references are always absolute -
whereas I need to make them relative (i.e. "go down 3 cells" rather than
"go
to A4").

What I have so far is:

Range("A1:C4").Select
Selection.Copy
Range("E1").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=True

Hope someone can help
Many thanks
Les





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
Recording a Macro Sharon Excel Discussion (Misc queries) 5 March 22nd 07 01:40 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 1 February 5th 07 09:31 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 3 February 5th 07 08:22 PM
Macro recording????? Chris Watson Excel Worksheet Functions 1 January 27th 06 09:31 AM
Macro recording Ron McCormick[_2_] Excel Programming 7 September 2nd 03 07:30 PM


All times are GMT +1. The time now is 10:07 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"