+ Reply to Thread
Results 1 to 12 of 12

VBA code that will re-apply my formula to the specific range of cells

  1. #1
    Registered User
    Join Date
    10-05-2013
    Location
    Manchester,England
    MS-Off Ver
    Excel 2010
    Posts
    18

    VBA code that will re-apply my formula to the specific range of cells

    Hi All

    I have an ongoing requirement that I'm trying to resolve within a sales order workbook. If Sales person has agreed a fixed price for subsequent sales order lines they enter the price in to sheet 1, and the pricing is pulled through to each order line on sheet 2. However if the Sales person has not agreed a fixed price for subsequent sales order line they manually enter the price in to the second sheet and overwrite the formula that was originally pulling through the price.

    My problem is now that the formula is overwritten and the workbook is now erroneous if reused to create another order as some order lines will contain the will the formula and some will not. Is there a VBA code that will reapply my formula to the specific range of cells that the user can run.

    Many thanks in advance.

  2. #2
    Forum Contributor
    Join Date
    08-04-2014
    Location
    Riga
    MS-Off Ver
    2010
    Posts
    579

    Re: VBA code that will re-apply my formula to the specific range of cells

    Is there a way to determine the exact range the formula needs to be applied to?

  3. #3
    Registered User
    Join Date
    10-05-2013
    Location
    Manchester,England
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: VBA code that will re-apply my formula to the specific range of cells

    Hi Bmouse

    Many thanks for a speedy response, would it help if I named the range "Sell" ?

    Regards

  4. #4
    Forum Contributor
    Join Date
    08-04-2014
    Location
    Riga
    MS-Off Ver
    2010
    Posts
    579

    Re: VBA code that will re-apply my formula to the specific range of cells

    What I mean't was - do you need to apply the formula to an entire row(s) or entire column(s), or random cells within a row(s), or random cells within a column(s), that kind of thing. Which is it?

  5. #5
    Registered User
    Join Date
    10-05-2013
    Location
    Manchester,England
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: VBA code that will re-apply my formula to the specific range of cells

    Sorry for that, I need the formula applying to selection of rows across several coloums, One issue that I have just thought abount would be that the user can insert new lines so the ranges may increase.
    Summary!$T50:$T58,Summary!$W50:$W58,Summary!$Z50:$Z58,Summary!$AC50:$AC58,Summary!$T$31:$T45,Summary!$W$31:$W45,Summary!$Z$31:$Z45,Summary!$AC$31:$AC45

    Thanks for your help.

  6. #6
    Forum Contributor
    Join Date
    08-04-2014
    Location
    Riga
    MS-Off Ver
    2010
    Posts
    579

    Re: VBA code that will re-apply my formula to the specific range of cells

    So, it seems that there is no pattern, where the formula will need to be entered, and that means all of these ranges will need to be entered in the macro manually.

  7. #7
    Registered User
    Join Date
    10-05-2013
    Location
    Manchester,England
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: VBA code that will re-apply my formula to the specific range of cells

    In theory I have two pricing tables and four levels or pricing per table:
    Table one Summary!$T50:$T58,Summary!$W50:$W58,Summary!$Z50:$Z58,Summary!$AC50:$AC58
    Table two Summary!$T$31:$T45,Summary!$W$31:$W45,Summary!$Z$31:$Z45,Summary!$AC$31:$AC45

  8. #8
    Forum Contributor
    Join Date
    08-04-2014
    Location
    Riga
    MS-Off Ver
    2010
    Posts
    579

    Re: VBA code that will re-apply my formula to the specific range of cells

    Irregular ranges are a tough pickle.

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,429

    Re: VBA code that will re-apply my formula to the specific range of cells

    It would probably help (a lot) if you posted a sample workbook. If you indicate the cells that need to be re-populated with a formula, and what that formula is, it should be possible to use a Workbook Open event handler to make the changes.

    That said it would perhaps be more secure if you were to save the workbook as a Template, and use New (from template) rather than Open, so that the user will need to save the updated workbook. Alternatively, save the original workbook as Read-Only so that, again, updates must be saved with a new file name.


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  10. #10
    Registered User
    Join Date
    10-05-2013
    Location
    Manchester,England
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: VBA code that will re-apply my formula to the specific range of cells

    Hi TMS

    I like your way of thinking, however please see the attached.

    If the sales person has individual pricing the enter in to the Contact sheet C61 F61 I61 L61 these pull through to the Summary tab and the sell ranges;
    Summary!$T50:$T58,Summary!$W50:$W58,Summary!$Z50:$Z58,Summary!$AC50:$AC58
    Summary!$T$31:$T45,Summary!$W$31:$W45,Summary!$Z$31:$Z45,Summary!$AC$31:$AC45

    Hope this helps

    Due to the file size restriction I have had to delete some sheets, so some formula may error, default password "bunny"
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    10-05-2013
    Location
    Manchester,England
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: VBA code that will re-apply my formula to the specific range of cells

    Hi All those who have helped

    It would appear that this requirement from my user is a sticky one - so I have tried to look at the issue in a different way and have identified that as opposed to reset a formula to a range of cells but to auto fill a formula on request. At the moment I have the below code which works on one column, but need to same to work with 4 different formula on four columns, can this be done?

    Please Login or Register  to view this content.
    Thanks in advance

  12. #12
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,429

    Re: VBA code that will re-apply my formula to the specific range of cells

    can this be done?
    almost certainly. But you'll need to provide more information ... like the columns and the formulae.

+ 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. Replies: 3
    Last Post: 06-24-2014, 11:04 AM
  2. [SOLVED] VBA Apply Formula to Non Blank Cells in Range
    By hobbiton73 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-02-2014, 11:58 AM
  3. [SOLVED] VBA Apply Formula to All Cells In Range
    By hobbiton73 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-20-2014, 09:25 AM
  4. [SOLVED] apply range.formula to multiple cells
    By union in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-08-2013, 07:53 PM
  5. Replies: 1
    Last Post: 01-23-2013, 03:00 PM
  6. vba code to apply a macro to a specific tab
    By 2seas in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-09-2012, 02:03 PM
  7. VBA code needed to apply formula to each value in a dynamic range!
    By burk in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-03-2006, 09:00 AM

Tags for this Thread

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