Hi,
I have written a macro and would like to know if there is a better way of doing it or just tidy it up a bit. I am still learning and any help or guidance would be much apreciated.
Regards Damian
I have written a macro and would like to know if there is a better way of doing it or just tidy it up a bit. I am still learning and any help or guidance would be much apreciated.
Code:
Sub UpdateTotals()
Dim WS As Worksheet
Dim Full As String
Dim Half As String
Dim SH As String
Application.ScreenUpdating = False
Sheets("Report").Activate
Range("Totals").ClearContents
For Each WS In ActiveWorkbook.Worksheets
If WS.Name = "Report" Then GoTo Nextws
If WS.Name = "Main" Then GoTo Nextws
If WS.Name = "Summary" Then GoTo Nextws
WS.Activate
SH = ActiveSheet.Name
Full = Range("B5").Value
Half = Range("C5").Value
With Sheets("Report")
lr = .Range("D" & Rows.Count).End(xlUp).Row
.Range("D" & lr + 1).Value = SH
.Range("E" & lr + 1).Value = Full
.Range("F" & lr + 1).Value = Half
End With
Nextws:
Next WS
Sheets("Report").Activate
Columns("D:D").Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
End With
Columns("E:F").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
End With
Range("C2:J4").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
Range("A1").Select
Application.ScreenUpdating = True
End Sub
Regards Damian