Hi All, I am new here and in VBA MAcro in excel 2007 but manage to create a code to run in a single worksheet. Is there anyone that can help to make this code/macro to run across all worksheets?? If so , many thanks in advance...below is my vba code /macro:
Sub transpose()
Application.ScreenUpdating = False
ActiveSheet.UsedRange.Copy
Sheets.Add After:=Sheets(Sheets.Count)
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
DateRowStart = 4 'Row on which the actual data starts
DateRowEnd = 51 'Row where the data ends for each column
ColStart = 2 'Column number of the first meter
NumDays = 1000 'Number of Days/Columns to cycle through
PastePoint = DateRowEnd + 1
For i = 0 To NumDays
Cells(3, ColStart + 1 + i).Select
Selection.Cut
Cells(PastePoint, 1).Select
ActiveSheet.Paste
Range(Cells(DateRowStart, ColStart + 1 + i), Cells(DateRowEnd, ColStart + 1 + i)).Select
Selection.Cut
Cells(PastePoint, 2).Select
ActiveSheet.Paste
PastePoint = PastePoint + 48
Next i
Range(Cells(1, 3), Cells(3, NumDays + 3)).Clear
Columns("B:B").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Selection.NumberFormat = "dd/mm/yyyy hh:mm"
Range("C3").Cut Destination:=Range("A4")
Range("B4").Select
ActiveCell.FormulaR1C1 = "=RC[-1]+TIME(0,30,0)"
Range("B5").Select
ActiveCell.FormulaR1C1 = "=R[-1]C+TIME(0,30,0)"
Columns("A:B").EntireColumn.AutoFit
Dim lastRow As Long
lastRow = Range("C" & Rows.Count).End(xlUp).Row
Range("B5").AutoFill Destination:=Range("B5:B" & lastRow)
Rows("2:3").Select
Selection.Delete
[B1].Value = "Timestamp "
Columns("B:B").Select
Selection.Copy
Columns("B:B").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Columns("B:B").ColumnWidth = 18
Columns("C:C").ColumnWidth = 12.44
Columns("A:A").Select
Selection.EntireColumn.Hidden = True
End sub
Bookmarks