+ Reply to Thread
Results 1 to 6 of 6

Add additional Formula using two VBA Formulas

  1. #1
    Registered User
    Join Date
    03-23-2017
    Location
    Windsor Locks, CT
    MS-Off Ver
    2013
    Posts
    38

    Add additional Formula using two VBA Formulas

    I'm trying to create another function formula in excel vba by using to other formula I've created. The two other formulas are in the last row on top of each other(pretty much offset by 1). Below that I would like to have a other formula which takes the value of those two cells and divides them and divides again by 8. A normal formula in a cell would look like =ROUND(O2/O3/8,0). Because my last two rows with the value is constantly changing(i.e.O30 and O31, then 13 and O14, etc...) I was think I can use the find the two last rows and offset them by 1 the use the formula to get the value that I need, but I'm getting a #NAME error. Here's my formulas below:

    Please Login or Register  to view this content.
    Everything works well except the last function. Any help would be greatly appreciated. Thanks!

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Add additional Formula using two VBA Formulas

    Hi don,

    I think this line won't work:
    Sheets("Daily Work").Range("O" & lastrow).Formula = "=ROUND(TotalHrs/Manpower/8, 0)"

    try
    Sheets("Daily Work").Range("O" & lastrow).Formula = "=ROUND(" & TotalHrs/Manpower/8 & ", 0)"
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    03-23-2017
    Location
    Windsor Locks, CT
    MS-Off Ver
    2013
    Posts
    38

    Re: Add additional Formula using two VBA Formulas

    MarvinP....Brilliant! Thank you!!

  4. #4
    Registered User
    Join Date
    03-23-2017
    Location
    Windsor Locks, CT
    MS-Off Ver
    2013
    Posts
    38

    Re: Add additional Formula using two VBA Formulas

    Actually Marvin....its not working like it should. The excel formula bar shows:

    =ROUND(0.119565217391304, 0)

    The info I currently am dividing is 36.20/2/8 = 2.26 which should round to 2.3, but I'm getting 0. Would you know why that is?

  5. #5
    Registered User
    Join Date
    03-23-2017
    Location
    Windsor Locks, CT
    MS-Off Ver
    2013
    Posts
    38

    Re: Add additional Formula using two VBA Formulas

    I think what the formul ais doing is taking the row count (i.e 23 (totalhrs) and 24(manpower)) then dividing it by 8, which leaves a value of zero. How can I identify the two cells as having 36.20 in O22 and 2 in O23 but making the row dynamic?

  6. #6
    Registered User
    Join Date
    03-23-2017
    Location
    Windsor Locks, CT
    MS-Off Ver
    2013
    Posts
    38

    Re: Add additional Formula using two VBA Formulas

    Ok MarvinP.....I figured it out. This is what the formula now reads:

    Sheets("Daily Work").Range("O" & lastrow).Formula = "=ROUND(" & Range("O" & TotalHrs) / Range("O" & Manpower) / 8 & ", 0)"

    Thanks for your help.

+ 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. [SOLVED] Add additional Data Validation for selection in INDIRECT formulas
    By suchetherrah in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-20-2016, 10:49 AM
  2. [SOLVED] Change formulas to include additional cells as I fill them in?
    By dtexter in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-05-2015, 05:29 PM
  3. [SOLVED] Additional variables for LOOKUP formulas
    By melbox in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-05-2014, 09:30 AM
  4. Adding additional cells in IF formulas
    By JakeMann in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-20-2012, 06:59 AM
  5. Replies: 0
    Last Post: 12-19-2012, 11:06 AM
  6. Adding additional rows & auto-applying formulas
    By ajxxx in forum Excel General
    Replies: 1
    Last Post: 11-26-2008, 12:35 PM
  7. [SOLVED] Macro to expand formulas to additional rows
    By Sharon P in forum Excel General
    Replies: 1
    Last Post: 01-04-2006, 10:10 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