+ Reply to Thread
Results 1 to 16 of 16

Help to understand a VBA Formulae function

  1. #1
    Forum Contributor Potholes's Avatar
    Join Date
    11-25-2011
    Location
    Brisbane
    MS-Off Ver
    Office 2021
    Posts
    774

    Help to understand a VBA Formulae function

    Good morning all and anyone game enough to look

    Below is a VBA code that was written for me, what I would like is if
    someone could go through the code and make a comment as to what
    each of the lines are doing.

    In doing so I am hoping this will help me to understand VBA.



    Please Login or Register  to view this content.

    Thank You in advance


    Regards

    Peter
    Last edited by Potholes; 08-10-2019 at 11:25 PM.
    One I have learnt over the last few months, " You are NEVER too old to learn ".
    Sometimes I forget to say " Thank You " for your assistance, so here I say " A BIG Thank You. "

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Help to understand a VBA Formulae function

    Is there any particular reason why you don't ask directly to the author of the code?

  3. #3
    Forum Contributor Potholes's Avatar
    Join Date
    11-25-2011
    Location
    Brisbane
    MS-Off Ver
    Office 2021
    Posts
    774

    Re: Help to understand a VBA Formulae function

    Good Morning

    I cannot remember who was the author, I have been asked to NOT approach the authors directly, else a wrap across the knuckles.

    Pete

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Help to understand a VBA Formulae function

    Yes you can ask in the original thread, but not via PM.

  5. #5
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,826

    Re: Help to understand a VBA Formulae function

    I find this page (https://docs.microsoft.com/en-us/off...overview/excel ) and this page (https://docs.microsoft.com/en-us/off...l/object-model ) are useful as they link to documentation for the VBA language and Excel's object model. If you have specific questions about a specific statement/object/method/property, these pages will help you understand the specifics of those items.

    Another set of tools that I find very useful for understanding VBA is the set of debugging tools: http://www.cpearson.com/Excel/DebuggingVBA.aspx I would suggest that you put a stop statement at the top of the procedure so you can step through the code and watch what it is doing (via watches, the locals window, etc.).
    Please Login or Register  to view this content.
    That said, here's what I see it doing:

    When a cell is changed, check to see if the changed cell was either D6 or D22 (that's the double negative Not intersect(...) is nothing statement). If so, then see if the entered value is in column A of sheet1 (using Excel's MATCH() function). If so, look for V or W in that row (using Excel's COUNTIF() function) and enter V or W in a cell 10 columns to the right of the changed cell. If a V or W was found, then flash this cell red and white 7 times and end the procedure with the cell colored red.

    Does that help?
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  6. #6
    Forum Contributor Potholes's Avatar
    Join Date
    11-25-2011
    Location
    Brisbane
    MS-Off Ver
    Office 2021
    Posts
    774

    Re: Help to understand a VBA Formulae function

    Mr Shorty ( I don't have your name to address you correctly)

    Please see my attachment screen grab when I try to log onto that Pearson site.
    Attached Files Attached Files

  7. #7
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,826

    Re: Help to understand a VBA Formulae function

    I'm not sure I can help with your malware blocker. As long as I have been aware of Chip's website, I have never seen or heard any reports of malware from his site.

    There are many other sites that describe VBA's debugging tools. I put "debug VBA" into my favorite search engine and found:
    https://www.excel-easy.com/vba/examples/debugging.html
    https://analystcave.com/how-to-debug-vba/
    and several others.

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Help to understand a VBA Formulae function

    Pete - the malware blocker on this occasion is most probably throwing a false positive - you can click to continue anyway, although if you do, always do so with caution

    The late Chip Pearson's site has been used for years and recommended by many: it was reinstated by Chip's family, after his untimely death, following an appeal to them by those who had always found the site useful. It's possible that the site's hosting architecture is a little old now, and that might be triggering the error message, but I doubt there's anything malicious there. I have just accessed it myself without my AV blinking.

    I agree that you should have posted in the thread where you acquired the code and asked for clarification there at the time it was given to you, but I am happy on this occasion for this thread to remain open since you can't remember when, where and who (despite there being a name at the top of the code snippet ...).

    No, you should not contact anyone via PM to ask them to look at your threads, as per the forum rules.
    Last edited by AliGW; 08-11-2019 at 01:59 AM.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  9. #9
    Forum Contributor Potholes's Avatar
    Join Date
    11-25-2011
    Location
    Brisbane
    MS-Off Ver
    Office 2021
    Posts
    774

    Re: Help to understand a VBA Formulae function

    Good Morning (Your Time) Mother ALiGW

    Re your LAST line in post #8 " NO WAY JOSE " This little black duck is NOT going to cross swords
    with one of his Educators here again.

    All I can do is to wait and hope someone picks up and does the coding for me or the original coder picks up the batton.

    Have a good week we currently have a ARCTIC blast of super cold air and winds here in the tropics atm Temp here in
    tropical Brisvagus is 7 degrees with snow on the mountains 50Km from here.

    Cheers

    P

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Help to understand a VBA Formulae function

    We have high winds, too - very unseasonal weather (autumnal). It hasn't been a cold summer, but it hasn't been a good one, either - I'm quite disappointed.

    I will comment on the bits I understand:


    Please Login or Register  to view this content.
    The uncommented section deals with what to return - V or W - but I'm not quite sure how it's doing it.

    PS Do you get Arctic blasts of cold air? Surely they are Antarctic blasts???
    Last edited by AliGW; 08-11-2019 at 02:38 AM.

  11. #11
    Forum Contributor Potholes's Avatar
    Join Date
    11-25-2011
    Location
    Brisbane
    MS-Off Ver
    Office 2021
    Posts
    774

    Re: Help to understand a VBA Formulae function

    HI Ali

    If I may could I ask you to Highlight in RED what your comments are please.

  12. #12
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Help to understand a VBA Formulae function

    Already done, but you only have to look for the ' in each line that indicates the start of the comment. If you copy this to your code in Excel, comments will show up in green.

  13. #13
    Forum Contributor Potholes's Avatar
    Join Date
    11-25-2011
    Location
    Brisbane
    MS-Off Ver
    Office 2021
    Posts
    774

    Re: Help to understand a VBA Formulae function

    Thank you I have printed that out so I may study it

  14. #14
    Forum Contributor Potholes's Avatar
    Join Date
    11-25-2011
    Location
    Brisbane
    MS-Off Ver
    Office 2021
    Posts
    774

    Re: Help to understand a VBA Formulae function

    Ali

    Do you know where the area is in that code that looks across " Sheet 1 " to look for the " V and W "
    content in the cells.

    If you can well and good if not "CE-LA-GARE"

    Pete

  15. #15
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,826

    Re: Help to understand a VBA Formulae function

    You've marked as solved, so I'm not sure if you are still looking for a response. The part that "looks for" (but really it counts) the "V" and "W" are the Countif functions inside of the block if that follows the Match() function (that finds the correct row to "count" in):
    Please Login or Register  to view this content.

  16. #16
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Help to understand a VBA Formulae function

    "CE-LA-GARE"
    That's a new one on me. Is it supposed to be French???

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Trying to Understand Lookup Function
    By cornes91 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-27-2019, 05:04 PM
  2. Need to decipher/understand this function
    By vpan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-30-2017, 03:33 PM
  3. [SOLVED] Please Explain and help me understand this Excel formulae !
    By omani in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 01-09-2017, 08:37 PM
  4. [SOLVED] Understand lookup, index & match formulae
    By Dushantha in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-18-2012, 05:50 AM
  5. Replies: 10
    Last Post: 04-18-2012, 07:30 AM
  6. Don't seem to understand QUOTIENT function
    By avhfj in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-29-2010, 12:01 PM
  7. Don't understand Lookup function
    By Beblessed in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 03-01-2006, 04:57 AM

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