Copy Range of cell and Transpose paste Macro

GERALDRAHMAN

New Member
Joined
Apr 11, 2013
Messages
38
Hi All

I need a macro that will copy data in range A1:Q1, Transpose to W2, and from A13:Q13 transpose paste to X2 and A1:Q1 transpose paste to M14 and A8:Q8 transpose paste to N14. This action should be for every worksheet in the workbook as the layout is uniform.

Many Thanks
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
if you want vb code then you can try below one
Code:
Sub Test()
my = ThisWorkbook.Worksheets.Count
Sheets(1).Select
Do Until ActiveSheet.Name = my
Range("A1:Q1").Copy
Range("W2").PasteSpecial xlPasteValues, Transpose:=True
Range("A13:Q13").Copy
Range("X2").PasteSpecial xlPasteValues, Transpose:=True
Range("A1:Q1").Copy
Range("M14").PasteSpecial xlPasteValues, Transpose:=True
Range("A8:Q8").Copy
Range("N14").PasteSpecial xlPasteValues, Transpose:=True
On Error GoTo GetLost
ActiveSheet.Next.Select
Loop
GetLost:
End Sub
 
Upvote 0
Aren't you missing the two lines (or at least the first one)?

Code:
Sub Test()
my = ThisWorkbook.Worksheets.Count
Sheets(1).Select
Do Until ActiveSheet.Name = my
Range("A1:Q1").Copy
Range("W2").PasteSpecial xlPasteValues, Transpose:=True
Range("A13:Q13").Copy
Range("X2").PasteSpecial xlPasteValues, Transpose:=True
Range("A1:Q1").Copy
Range("M14").PasteSpecial xlPasteValues, Transpose:=True
Range("A8:Q8").Copy
Range("N14").PasteSpecial xlPasteValues, Transpose:=True
[SIZE=3][COLOR=#ff0000][B]Application.CutCopyMode = False
Range("A1").Select[/B][/COLOR][/SIZE]
On Error GoTo GetLost
ActiveSheet.Next.Select
Loop
GetLost:
End Sub
 
Upvote 0
that is optional if you will not use those line even macro work perfects
 
Upvote 0
Well yeah, "optional" as in not needed for the code to work, but still, the code should clean after itself, shouldn't it?

(Sorry if I came out as a pain in the @ss, that wasn't intended)
 
Upvote 0

Forum statistics

Threads
1,206,921
Messages
6,075,584
Members
446,147
Latest member
homedecortips

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