+ Reply to Thread
Results 1 to 11 of 11

Continue formulas in next rows VBA

  1. #1
    Forum Contributor
    Join Date
    11-09-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2013
    Posts
    391

    Continue formulas in next rows VBA

    Hi All,

    I have a spreadsheet which contains some formulas in some cells (see attached for better understanding). There is a table in the spreadsheet which starts from column B to clumn J. By inputting values to cells in Column C and D the rest of the cells in that row will do some calculations as it is clear in the spreadsheet. instead of dragging down the formulas is there any way in VBA to define if the cells in column B (or C or D) not empty then do the calculations in that row. i.e if "B12" is not empty do the calculations (E12 to J12) and then move on to the next row and so on..... I hope it is clear!

    Thanks,
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    01-03-2016
    Location
    Conwy, Wales
    MS-Off Ver
    2016
    Posts
    974

    Re: Continue formulas in next rows VBA

    The way to do this is to create an Excel Table (Go to "Insert" tab and click on Table)

    See you workbook which has been modified. Now when you add something in column B formulas and formats etc are auto-created in other columns
    Attached Files Attached Files
    If a response has helped then please consider rating it by clicking on *Add Reputation below the post
    When your issue has been resolved don't forget to mark the thread SOLVED (click Thread Tools at top of thread)

  3. #3
    Forum Contributor
    Join Date
    11-09-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2013
    Posts
    391

    Re: Continue formulas in next rows VBA

    Thanks for your reply Kevin but the problem in this case is data in column B, C and D will be inserted by a piece of code which search for the last row and insert data. when I delete data for new entries the last row will be the last row that table created i.e if I insert data in row 12 to 15 and delete the data and insert new set of data it will start from row 16.

    the alternative solution to this is, if possible, clear the table as well as data which I don't know any VBA code for it.

  4. #4
    Valued Forum Contributor
    Join Date
    01-03-2016
    Location
    Conwy, Wales
    MS-Off Ver
    2016
    Posts
    974

    Re: Continue formulas in next rows VBA

    Will there be values in all 3 columns (B,C & D) if there is a value in any one of them?
    (need to tell VBA where to stop adding formulas)

  5. #5
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Continue formulas in next rows VBA

    Delete Rows 12 to 20

    Right Click on the sheet name at the bottom of excel and select view code

    Paste this code into the module that opens and close it.

    You are ready to go.

    Please Login or Register  to view this content.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  6. #6
    Valued Forum Contributor
    Join Date
    01-03-2016
    Location
    Conwy, Wales
    MS-Off Ver
    2016
    Posts
    974

    Re: Continue formulas in next rows VBA

    I have assumed there will always be values in Column B
    - if you want formulas in the cells use Option1
    - for values only use Option2

    The attached workbook includes 2 sheets to illustrate both (formulas in sheet1, and values in sheet2)

    Option1
    Please Login or Register  to view this content.
    Option2
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Kevin#; 05-10-2016 at 12:37 AM.

  7. #7
    Forum Contributor
    Join Date
    11-09-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2013
    Posts
    391

    Re: Continue formulas in next rows VBA

    Thank you both. All 3 options work perfectly.

  8. #8
    Forum Contributor
    Join Date
    11-09-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2013
    Posts
    391

    Re: Continue formulas in next rows VBA

    It works perfectly but I have one concern here. I need to add a push button and assign the macro to run the code and the calculations and calculations won't be shown until i click the button. What should I do the calculations will be shown automatically when column B,C and D (or either of them) has value?

    Cheers

    Quote Originally Posted by Kevin# View Post
    I have assumed there will always be values in Column B
    - if you want formulas in the cells use Option1
    - for values only use Option2

    The attached workbook includes 2 sheets to illustrate both (formulas in sheet1, and values in sheet2)

    Option1
    Please Login or Register  to view this content.
    Option2
    Please Login or Register  to view this content.

  9. #9
    Valued Forum Contributor
    Join Date
    01-03-2016
    Location
    Conwy, Wales
    MS-Off Ver
    2016
    Posts
    974

    Re: Continue formulas in next rows VBA

    If you want the macro to run automatically then insert this line (in the code that updates columns B:D) after that code has updated the values in columns B:D

    Please Login or Register  to view this content.
    (or Call AddValues)
    Last edited by Kevin#; 05-10-2016 at 07:01 AM.

  10. #10
    Forum Contributor
    Join Date
    11-09-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2013
    Posts
    391

    Re: Continue formulas in next rows VBA

    You're a star!


    Quote Originally Posted by Kevin# View Post
    If you want the macro to run automatically then insert this line (in the code that updates columns B:D) after that code has updated the values in columns B:D

    Please Login or Register  to view this content.
    (or Call AddValues)

  11. #11
    Valued Forum Contributor
    Join Date
    01-03-2016
    Location
    Conwy, Wales
    MS-Off Ver
    2016
    Posts
    974

    Re: Continue formulas in next rows VBA

    Glad it works for you and thanks for the reps!

+ 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. Every Two Rows - Insert Formula -> Continue for as many rows as there is data.
    By athyeh in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-10-2014, 04:15 PM
  2. [SOLVED] Code to add rows and continue formulas
    By Nitefox in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-26-2014, 10:03 PM
  3. Code to add rows and continue formulas needs tweaking
    By Nitefox in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-26-2014, 09:25 PM
  4. [SOLVED] Last instance - Insert Row - Continue formulas Project
    By Fett2oo5 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-14-2013, 10:53 AM
  5. Macro - Insert Row and continue formulas
    By Fett2oo5 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-29-2013, 11:38 AM
  6. Replies: 5
    Last Post: 01-24-2012, 08:54 PM
  7. [SOLVED] Textbox and label formulas-continue
    By damorrison in forum Excel General
    Replies: 3
    Last Post: 03-12-2006, 02: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