Results 1 to 11 of 11

Help Understanding Some Code

Threaded View

  1. #1
    Registered User
    Join Date
    07-10-2019
    Location
    New York, NY
    MS-Off Ver
    MS Office 2016
    Posts
    30

    Help Understanding Some Code

    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!
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Understanding VBA Code
    By Moa88 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-30-2019, 08:49 AM
  2. Understanding this code
    By vj2651 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-13-2018, 11:12 PM
  3. [SOLVED] Understanding code
    By K243 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-09-2018, 04:19 AM
  4. Help with understanding VBA code
    By snaik in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-05-2014, 04:22 PM
  5. need help understanding a bit of code
    By lazerphazer21 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-24-2013, 10:11 PM
  6. Understanding this VBA code
    By rez9000 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-28-2010, 10:14 AM
  7. understanding code
    By karinos57 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-12-2009, 08:35 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1