C
cheekyblue
Hi I need a macro but I really dont know what I am doing. I have a
spreadsheet with (sheet 1) data in columns A & B, Column A has a date and
time starting with mid-night and going up in half-hour increments, so 48 for
each day, Column B has data for each half-hour. I need to copy and paste each
day at a time (onto sheet 2) and transpose it so that I have a Date in A1,
half-hour 1 in A2, half-hour 2 in A3 etc. I can get it to do this but then
when i run my macro repeatedly it copies day 2 over day 1 etc.
Can anyone help me get the code right so that is choses the next available
row (sheet 2) to paste into and loop until there are no more days left (Sheet
1). The number of days will vary from month to month and I also may need this
quarterly so no upper bound on the loop if possible.
I kinda get the concept I just dont have enough experience to do this
myself, below is what I have managed through the "Record Macro" function in
excel.
Sub Data_Transpose()
'
' Data_Transpose Macro
'
'
Sheets("Sheet1").Select
Range("A1").Select
Selection.Copy
Sheets("Sheet2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Range("B1:B48").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet2").Select
Range("B1").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=True
Sheets("Sheet1").Select
ActiveWindow.SmallScroll Down:=24
Range("A1:B48").Select
Range("B48").Activate
Application.CutCopyMode = False
Selection.Delete Shift:=xlUp
Sheets("Sheet2").Select
Range("A2").Select
Columns("A:A").EntireColumn.AutoFit
End Sub
spreadsheet with (sheet 1) data in columns A & B, Column A has a date and
time starting with mid-night and going up in half-hour increments, so 48 for
each day, Column B has data for each half-hour. I need to copy and paste each
day at a time (onto sheet 2) and transpose it so that I have a Date in A1,
half-hour 1 in A2, half-hour 2 in A3 etc. I can get it to do this but then
when i run my macro repeatedly it copies day 2 over day 1 etc.
Can anyone help me get the code right so that is choses the next available
row (sheet 2) to paste into and loop until there are no more days left (Sheet
1). The number of days will vary from month to month and I also may need this
quarterly so no upper bound on the loop if possible.
I kinda get the concept I just dont have enough experience to do this
myself, below is what I have managed through the "Record Macro" function in
excel.
Sub Data_Transpose()
'
' Data_Transpose Macro
'
'
Sheets("Sheet1").Select
Range("A1").Select
Selection.Copy
Sheets("Sheet2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Range("B1:B48").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet2").Select
Range("B1").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=True
Sheets("Sheet1").Select
ActiveWindow.SmallScroll Down:=24
Range("A1:B48").Select
Range("B48").Activate
Application.CutCopyMode = False
Selection.Delete Shift:=xlUp
Sheets("Sheet2").Select
Range("A2").Select
Columns("A:A").EntireColumn.AutoFit
End Sub