Hi, I need help with Visual Basic. I only know how to record macros (which results in very long scripts), and need help with this code.
Background info:
I have 2 worksheets in this file:
1 – Calculator (which I will key in some numbers).
2 – Summary (which, at the click of a button, I want the data from Calculator transposed into, to the next blank row).
At present, the recorder records my action for 3 parts:
1 – Data from D3:N3 of Calculator, and transpose them to column B of Summary (it’s supposed to go to the next blank row, and I need help doing). Note: At present I have data up to column N, but this will expand soon to more columns.
2 – Data from D23:N23, and transpose them to column C of Summary (it’s supposed to go to the next blank row, and I need help doing). Note: At present I have data up to column N, but this will expand soon to more columns.
3 – A single cell B2 and copy-paste value it to column A (which will fill in all the cells until the last row where the last piece of data stops (i.e. at present, 11 rows down).
I need help in:
1 – To review my code, and simplify it
2 – To be able to append my data, at the click of a button, to the next blank row in Summary
3 – To help me understand the codes so that I can change the codes with my columns expand.
This is my code:
Thanks!
Background info:
I have 2 worksheets in this file:
1 – Calculator (which I will key in some numbers).
2 – Summary (which, at the click of a button, I want the data from Calculator transposed into, to the next blank row).
At present, the recorder records my action for 3 parts:
1 – Data from D3:N3 of Calculator, and transpose them to column B of Summary (it’s supposed to go to the next blank row, and I need help doing). Note: At present I have data up to column N, but this will expand soon to more columns.
2 – Data from D23:N23, and transpose them to column C of Summary (it’s supposed to go to the next blank row, and I need help doing). Note: At present I have data up to column N, but this will expand soon to more columns.
3 – A single cell B2 and copy-paste value it to column A (which will fill in all the cells until the last row where the last piece of data stops (i.e. at present, 11 rows down).
I need help in:
1 – To review my code, and simplify it
2 – To be able to append my data, at the click of a button, to the next blank row in Summary
3 – To help me understand the codes so that I can change the codes with my columns expand.
This is my code:
Code:
Sub Transpose()
'
' Transpose Macro
'
'
Range("D3").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Sheets("Summary").Select
Range("B2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=True
Sheets("Calculator").Select
Range("D23").Select
Range(Selection, Selection.End(xlToRight)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Summary").Select
Range("C2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=True
Sheets("Calculator").Select
Range("C1").Select
Selection.End(xlToLeft).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Summary").Select
Range("A2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Selection.AutoFill Destination:=Range("A2:A12"), Type:=xlFillDefault
Range("A2:A12").Select
End Sub
Thanks!