Renaissance
Board Regular
- Joined
- Jun 20, 2013
- Messages
- 58
Greetings!
I am working on a simple macro that will copy a header row and other row within the same sheet and pasting it into a new sheet. This action repeats until all rows have been copied, however right now I am getting a "This action won't work on multiple selections" error '1004' and can't figure out why.
Here's the code
I'm assuming it's something simple and I've eyeballed code from a few others, but I appreciate any advice you can offer
~Renaissance
I am working on a simple macro that will copy a header row and other row within the same sheet and pasting it into a new sheet. This action repeats until all rows have been copied, however right now I am getting a "This action won't work on multiple selections" error '1004' and can't figure out why.
Here's the code
Code:
Sub Transpose()
Dim cnt As Integer
Dim i As Integer
Dim clmns As Integer
Dim range1 As Range
Dim range2 As Range
Dim myMultipleRange As Range
Sheets("Sheet1").Activate
clmns = Worksheets("Sheet1").Range("1:1").Cells.SpecialCells(xlCellTypeConstants).Count
cnt = Worksheets("Sheet1").Range("B:B").Cells.SpecialCells(xlCellTypeConstants).Count
Set range1 = Worksheets("Sheet1").Range("B1:B" & clmns)
For i = 2 To cnt
Set range2 = Sheets("Sheet1").Range(Cells(i, 2), Cells(i, clmns))
Set myMultipleRange = Union(range1, range2)
myMultipleRange.Select
Selection.Copy
Sheets.Add After:=ActiveSheet
Range("B1").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
Sheets("Sheet1").Select
Next i
End Sub
I'm assuming it's something simple and I've eyeballed code from a few others, but I appreciate any advice you can offer
~Renaissance