I got some help with a code the other day and I'm trying to understand how it works. I started making some notes for myself but got confused after a certain point. Could someone please try to explain in layman's terms what the following code does?
Option Explicit
Sub Data_Summary_Macro()
'Defines dynamic value in code
Const C = 12
'Defines dynamic ranges in code
Dim R&, S&, Rf As Range
'Clears any previous data after the first row
UsedRange.Offset(1).Clear
'Turns off screen updates
Application.ScreenUpdating = False
'Defines dynamic value in code
R = 2
'Defines S as 2 through the total number of sheets
For S = 2 To Sheets.Count
'Starting with sheet #2, define Rf as the used range, column 2, the row after where "Name & ..." first appear
With Sheets(S)
Set Rf = .UsedRange.Columns(2).Find("Name & *", , xlValues, 1)
If Not Rf Is Nothing Then
With .Range("B9", .[B8].End(xlDown)).Resize(, C).Rows
Cells(R, 1).Resize(.Count, 5).Value = Array(.Parent.Name, Rf(0).MergeArea(1).Text, Rf(2).Text, _
.Cells(-3, 2).Value, .Cells(-3, 4).Value)
Cells(R, 6).Resize(.Count, C).Value = .Value
R = R + .Count
End With
End If
End With
'Restarts above action with next sheet
Next
'Turns screen updating back on
Application.ScreenUpdating = True
Set Rf = Nothing
End Sub
I've also attached the example workbook so you can see the context.
Thanks very much!
Bookmarks