+ Reply to Thread
Results 1 to 3 of 3

VBA help understanding what this means

  1. #1
    Registered User
    Join Date
    07-21-2010
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    5

    VBA help understanding what this means

    can anyone help me with this string of code? I need to tweak it but need to know what it means first? Thank you!!!!
    Please Login or Register  to view this content.
    Last edited by Leith Ross; 07-21-2010 at 05:01 PM. Reason: Added Code Tags

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: VBA help understanding what this means

    Given the snippet it's pretty much impossible for anyone to give you detailed analysis, however, what we can say is:

    Target : will be a Range reference of some sort (presumably in Col B)
    (we don't know if this is a Change Event driven piece of code or someone has decided to name a variable Target)

    bAddSupport: will be a Boolean variable (ie True/False)

    ws: will be a Worksheet variable

    The code essential states that if bAddSupport is True

    Please Login or Register  to view this content.
    then to offset from the Target range by 2 cells in a downwards direction and set that cell to contain value "Support & Maintenance".

    Please Login or Register  to view this content.
    Then using the "ws" worksheet...

    Please Login or Register  to view this content.
    use the Range B10 to ? where ? is determined by offsetting from the Target range by 8 columns to the right

    Please Login or Register  to view this content.
    then:

    -- Offset from the original Target Range by 3 cells in a downwards direction and and subsequently resize that resulting Range by the number of rows identified in the B10:? range and to 9 columns in width
    -- to that range assign the value of the B10:? range

    Please Login or Register  to view this content.
    -- Then offset from the Target range by 3 rows in a downwards direction and 4 columns to the right and subsequently resize the resulting range by the number of rows identified in the B10:? range and to 4 columns in width

    Please Login or Register  to view this content.
    -- to that range assign the formula specified

    Please Login or Register  to view this content.
    uses R1C1 notation and basically uses a relative cell reference determined by the inverse of the number of rows previously identified in the B10:? range + 2 further rows and the current column - the value of which is then multiplied by the value as stored in the Support Named Range / Constant

    To elaborate - if current cell was say D30 and there were 10 rows in B10:? range then the above would read in D30 as:

    =D18*Support

    ie D30 offset upwards by 12 rows

    For more info. on R1C1 notation - I put together a very brief overview a while back:

    http://www.excelforum.com/2171545-post2.html
    Last edited by DonkeyOte; 07-22-2010 at 03:02 AM. Reason: added CODE snippets for clarity

  3. #3
    Registered User
    Join Date
    07-21-2010
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: VBA help understanding what this means

    this is super helpful!!!! It's doing exactly what you explained - I've been tasked with tweaking this and can see what it's doing but didn't understand the written code. I just posted another post wondering if it's possible for that same set of code to look at another sheet and pull those results into this sheet? I'm wondering if I just need to somehow tweak this row of code? It's always going to be a moving target depending on how many choices people make so B10 is really the starting point. -- Thanks again!
    .FormulaR1C1 = "=R[-" & .Rows.Count + 2 & "]C * Support"

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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