+ Reply to Thread
Results 1 to 10 of 10

Formula to VBA Code

  1. #1
    Forum Contributor
    Join Date
    11-25-2018
    Location
    Philippines
    MS-Off Ver
    Ms Office 365
    Posts
    217

    Formula to VBA Code

    Hi, is it possible to make these formulas run into the background through VBA?

    In "PPMP I (3)" sheet columns E and F, there are index+match formulas to generate unit and unit costs from the "APP PART A 2022".
    It works. However, there were times that I must replace the formula and manually enter the UNIT and UNIT COST that are not to be found in "APP PART A 2022".
    With this, the formula is erased. What I think is if it is possible to make this formula work in the background without inputting the formula in columns E and F.
    If those columns were filled with values/data manually, Index+Match through VBA will not work but if it is left emply, the VBA will work as Index+Match.

    I hope I made it clear. :D

    Hoping for someone could help me on this.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,178

    Re: Formula to VBA Code

    What is the issue with overwriting a formula in a given row?

    With VBA, you can trigger the INDEX/MATCH equivalent on entry of data in column C if no match is found, VBA does nothing i.e E and F are left blank. This OK ?
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  3. #3
    Forum Contributor
    Join Date
    11-25-2018
    Location
    Philippines
    MS-Off Ver
    Ms Office 365
    Posts
    217

    Re: Formula to VBA Code

    The issue is some users of this form are skeptical and they change minds to what item they entered in column C. Yes. whenever data is entered in column C, the formula should be triggered and look for the UNIT and UNIT COST from the other sheet. Sometimes, some users have no idea how to recover the formula when replaced with manually entered data that cannot be found from other sheet.
    Last edited by archvanarl; 08-05-2022 at 01:59 AM.

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,178

    Re: Formula to VBA Code

    Please Login or Register  to view this content.
    The following in a standard module
    Please Login or Register  to view this content.
    Highlighted in attached are via VBA
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    11-25-2018
    Location
    Philippines
    MS-Off Ver
    Ms Office 365
    Posts
    217

    Re: Formula to VBA Code

    Hi, it works! I manage to ignore the error when data on the cells are deleted by using "On Error Resume Next"

    Please Login or Register  to view this content.
    However, whenever I paste (CTRL+V) from the other sheet and select multiple items to paste in column C, UNIT PRICE and UNIT are not generating. Could you help me further on this? Also, when the cells on column C is empty again, should the cells on column E and F be empty also.
    Last edited by archvanarl; 08-05-2022 at 09:46 AM.

  6. #6
    Forum Contributor
    Join Date
    11-25-2018
    Location
    Philippines
    MS-Off Ver
    Ms Office 365
    Posts
    217

    Re: Formula to VBA Code

    Bump for help.

  7. #7
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,178

    Re: Formula to VBA Code

    I was curious as how you entered data "manually" without lots of potential typos: now I know!

    Will re-look at code.
    Last edited by JohnTopley; 08-06-2022 at 08:44 AM.

  8. #8
    Forum Contributor
    Join Date
    11-25-2018
    Location
    Philippines
    MS-Off Ver
    Ms Office 365
    Posts
    217

    Re: Formula to VBA Code

    Yep, data are mostly copied and pasted using crtl + v. It is working when I copy and paste a single cell in but it could be time consuming to copy and paste one by one. Is there a workaround on this to work this with multiple cells to be pasted at the same in column C?
    Last edited by archvanarl; 08-06-2022 at 06:05 AM.

  9. #9
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,178

    Re: Formula to VBA Code

    Try

    Replace code in MODULE

    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    11-25-2018
    Location
    Philippines
    MS-Off Ver
    Ms Office 365
    Posts
    217

    Re: Formula to VBA Code

    Perfect! I will use this to the original file. For now, solved!

+ 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. writing vba code to fill in column of sheet, formula works vba code will not
    By pdx2245 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-28-2019, 05:15 PM
  2. Writing a Formula using R1C1 code in VBA code
    By e4excel in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-15-2014, 11:06 AM
  3. Replies: 1
    Last Post: 11-13-2013, 10:28 AM
  4. Advice and help with a copy past code or filldown formula code
    By KELLIS in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-14-2013, 02:07 PM
  5. Help: formula or VB code to implement voting system code
    By cdsc in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-24-2013, 01:23 AM
  6. [SOLVED] Array Formula vs vBa code - How To Modify My Messy Code To One Of Those
    By ScotyB in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-20-2012, 12:04 AM
  7. Sumproduct formula:Empl Code Payroll Code Amount
    By bluemeg in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-30-2009, 02:08 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