Dear all,
I'm not used to programming in excel, but I have an issue where I need to transform data from one sheet (sheet 2) in to a different order on a different sheet (sheet 4) to enable me to enter data in to a database which is a specific format. The data is in specific cells so it's not a function to copy a row.
I have to copy data from Cell A5 on sheet 2 and paste it 12 times in to column
A on sheet 4. I then need to effectively transpose the data from cells N5 - Y5 from sheet 2 in to cells G1 - G12 on sheet 4.
I need to then repeat this action for each row in sheet 2.
My basic code from a simple recorded macro is as follows. It is not looped or Variabled at the moment but that's the issue I am trying to get help with.
I look forward to your assistance and many thanks in advance.
I'm not used to programming in excel, but I have an issue where I need to transform data from one sheet (sheet 2) in to a different order on a different sheet (sheet 4) to enable me to enter data in to a database which is a specific format. The data is in specific cells so it's not a function to copy a row.
I have to copy data from Cell A5 on sheet 2 and paste it 12 times in to column
A on sheet 4. I then need to effectively transpose the data from cells N5 - Y5 from sheet 2 in to cells G1 - G12 on sheet 4.
I need to then repeat this action for each row in sheet 2.
My basic code from a simple recorded macro is as follows. It is not looped or Variabled at the moment but that's the issue I am trying to get help with.
Code:
Sub Macro2()
Sheets("Sheet2").Select
Range("A5").Select
Selection.Copy
Sheets("Sheet4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A2").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=R[-1]C"
Range("A3").Select
ActiveCell.FormulaR1C1 = "=R[-2]C"
Range("A4").Select
ActiveCell.FormulaR1C1 = "=R[-3]C"
Range("A5").Select
ActiveCell.FormulaR1C1 = "=R[-4]C"
Range("A6").Select
ActiveCell.FormulaR1C1 = "=R[-5]C"
Range("A7").Select
ActiveCell.FormulaR1C1 = "=R[-6]C"
Range("A8").Select
ActiveCell.FormulaR1C1 = "=R[-7]C"
Range("A9").Select
ActiveCell.FormulaR1C1 = "=R[-8]C"
Range("A10").Select
ActiveCell.FormulaR1C1 = "=R[-9]C"
Range("A11").Select
ActiveCell.FormulaR1C1 = "=R[-10]C"
Range("A12").Select
ActiveCell.FormulaR1C1 = "=R[-11]C"
Range("A13").Select
Sheets("Sheet2").Select
Range("N5").Select
Selection.Copy
Sheets("Sheet4").Select
Range("B1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Sheet2").Select
Range("O5").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet4").Select
Range("G2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Sheet2").Select
Range("P5").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet4").Select
Range("G3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Sheet2").Select
Range("Q5").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet4").Select
Range("g4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Sheet2").Select
Range("R5").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet4").Select
Range("g5").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Sheet2").Select
Range("S5").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet4").Select
Range("g6").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Sheet2").Select
Range("T5").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet4").Select
Range("g7").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Sheet2").Select
Range("U5").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet4").Select
Range("g8").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Sheet2").Select
Range("V5").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet4").Select
Range("g9").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Sheet2").Select
Range("W5").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet4").Select
Range("g10").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Sheet2").Select
Range("X5").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet4").Select
Range("g11").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Sheet2").Select
Range("Y5").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet4").Select
Range("g12").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub
I look forward to your assistance and many thanks in advance.