CopyPasteTransform Macro to new sheet Macro Question

MrsMSalt91

New Member
Joined
Nov 7, 2018
Messages
1
New to VBA, using Excel 2013. I am trying to select a rage columns and rows to copy and paste and transpose into a new sheet. I have searched for anything close and have not been successful. I am including my raw data then a generic walkthrough of what I need the Macro to do. My issue is, I need to create a variable for the ranges because after the first selected copy and paste which would be A2:B10, then paste transposed to Sheet2 A1. The macro needs to then select A11:B10 (always 9 rows) select those then paste transformed to Sheet2 A3. Please let me know if I am totally confusing you all.

QUESTION
SERVICEIN
VARNAMEA1
QUESTION_TEXTSpeed of admission process
SECTIONAdmission
STANDARDY
SCREENINGN
TOP_BOX_SCALE
TOP_BOX_ANSWER
QUESTION
SERVICEIN
VARNAMEA2
QUESTION_TEXTCourtesy of the person who admitted you
SECTIONAdmission
STANDARDY
SCREENINGN
TOP_BOX_SCALE
TOP_BOX_ANSWER
QUESTION
SERVICEIN
VARNAMEAGE
QUESTION_TEXTPatient's age
SECTIONBackground
STANDARD
SCREENING
TOP_BOX_SCALE
TOP_BOX_ANSWER

<tbody>
</tbody>

<tbody>
</tbody>

This is what I need it to look like:
QUESTIONSERVICEVARNAMEQUESTION_TEXTSECTIONSTANDARDSCREENINGTOP_BOX_SCALETOP_BOX_ANSWER
INA1Speed of admission processAdmissionYN
QUESTIONSERVICEVARNAMEQUESTION_TEXTSECTIONSTANDARDSCREENINGTOP_BOX_SCALETOP_BOX_ANSWER
INA2Courtesy of the person who admitted youAdmissionYN
QUESTIONSERVICEVARNAMEQUESTION_TEXTSECTIONSTANDARDSCREENINGTOP_BOX_SCALETOP_BOX_ANSWER
INAGEPatient's ageBackground

<tbody>
</tbody>


Here is the VBA Macro I created by just stepping through the process:

Sub CopyPasteTransform()
'
' CopyPasteTransform Macro
'
' Keyboard Shortcut: Ctrl+Shift+G
'
Range("A2:B10").Select
Selection.Copy
Sheets("Transformed").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
Sheets("Main").Select
Range("A11:B19").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Transformed").Select
Range("A3").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
Sheets("Main").Select
Range("A20:B28").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Transformed").Select
Range("A5").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
End Sub


Any help you can offer I would be GREATLY appreciative!
Thanks,
Marianne
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Try this:
Code:
Sub Copy_Transform()
'Modified  11/8/2018  2:14:35 AM  EST
Application.ScreenUpdating = False
Sheets("Main").Activate
Dim i As Long
Dim Lastrow As Long
Lastrow = Sheets("Main").Cells(Rows.Count, "A").End(xlUp).Row
Dim ans As Long
ans = 1
    For i = 1 To Lastrow Step 9
        Sheets("Main").Cells(i, 1).Resize(9, 2).Copy
        Sheets("Transformed").Cells(ans, 1).PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:=False, Transpose:=True
        ans = ans + 2
    Next
    Application.CutCopyMode = Talse
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,415
Messages
6,124,768
Members
449,187
Latest member
hermansoa

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