+ Reply to Thread
Results 1 to 4 of 4

Convert Formulas into VBA

  1. #1
    Registered User
    Join Date
    06-14-2012
    Location
    California
    MS-Off Ver
    Office 365
    Posts
    56

    Convert Formulas into VBA

    How can I convert the following formulas into VBA?
    =IF(ISBLANK(C2),"",VLOOKUP(C2,Inventory!$A$2:D37812,3,FALSE))
    =IF(ISBLANK(C2),"",VLOOKUP(C2,Inventory!$A$2:D37812,4,FALSE))
    =IF(ISBLANK(C2),"",VLOOKUP(C2,Inventory!$A$2:D37812,2,FALSE))
    =IF(C3="","",A2)
    Each one needs to go down the entire range of rows. Sample spreadsheet is attached.
    Attached Files Attached Files

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Convert Formulas into VBA

    The basic construct for one formula is

    Please Login or Register  to view this content.
    To get the coding for the other formulas, turn on the macro recorder, put the cursor in E2 >> hit F2 >> tab

    Repeat this process for the other cells.
    HTH
    Regards, Jeff

  3. #3
    Registered User
    Join Date
    06-14-2012
    Location
    California
    MS-Off Ver
    Office 365
    Posts
    56

    Re: Convert Formulas into VBA

    I kind of understand what you mean, but not all the way. I tried what you said, but it did not work. Can you explain a little more please?

  4. #4
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Convert Formulas into VBA

    Before you begin, make sure you lock the table reference which means placing the dollar signs around the column and row.

    The formula in E2 should look like this

    Please Login or Register  to view this content.
    In D2, E2, and F2 you have formulas. Put your cursor in D2 >> Developer tab on ribbon >> Record Macro

    Now place your cursor in the formula bar or select the F2 key which does the same thing.

    Hit the tab key which will place your cursor now in E2 and repeat the steps above.

    Hit the tab key again and now you are in F2 and repeat.

    Open up the VBE >> Alt + F11

    All the recorded formulas are now in a module

    Please Login or Register  to view this content.

+ 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