+ Reply to Thread
Results 1 to 4 of 4

Using VBA to round a function and place result in cell

  1. #1
    Forum Contributor
    Join Date
    11-17-2004
    MS-Off Ver
    Office 2016
    Posts
    527

    Using VBA to round a function and place result in cell

    I've used some VBA code to place a formula into a cell but I'd like to perform the calculation in VBA instead if it's possible. The trouble I'm having is that the values and the result are all on different pages and I'm unfamiliar with how to reference each data point for the Round function

    I started with putting a formula in the cell using:
    • Sheet3.Range("H8") = "Round('Unit Data'!E3*'Rate Data'!A39,0)"

    For example
    • On Sheet1 I have a value in cell E3, 11
    • On Sheet2 I have a multiplier in cell A39, 60%
    • On Sheet3 I have a field for the result H8

    My hope is that the result of "7" ends up in Sheet3 cell H8.

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

    Re: Using VBA to round a function and place result in cell

    Try:

    •Sheet3.Range("H8") = worksheetfunction.Round(Sheets("Unit Data").range(E3)+sheets("Rate Data").range(A39),0)
    Last edited by MarvinP; 05-12-2016 at 11:42 AM.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Using VBA to round a function and place result in cell

    Or maybe.
    Please Login or Register  to view this content.
    and in sheet3!h8
    Please Login or Register  to view this content.
    @MarvinP

    Early in the morning ?
    Please Login or Register  to view this content.
    Last edited by bakerman2; 05-12-2016 at 01:36 AM.

  4. #4
    Forum Contributor
    Join Date
    11-17-2004
    MS-Off Ver
    Office 2016
    Posts
    527

    Re: Using VBA to round a function and place result in cell

    Thank all, MarvinP's solution was what I needed. Much appreciated

+ 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] How to round to nearest .01 and round down if thousands place is .005
    By dredre609 in forum Excel General
    Replies: 5
    Last Post: 09-29-2014, 11:47 AM
  2. Round the result of IFERROR / VLOOK function
    By ZJosephine in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-13-2011, 08:15 PM
  3. round up a function RESULT
    By Lynne in forum Excel General
    Replies: 4
    Last Post: 11-10-2005, 01:10 PM
  4. [SOLVED] How to round up the result in a cell containing formula
    By cmart02 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 09-06-2005, 07:05 AM
  5. How to round up the result in a cell containing formula
    By cmart02 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-06-2005, 04:05 AM
  6. [SOLVED] How to round up the result in a cell containing formula
    By Mostropovich in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 02:05 AM
  7. [SOLVED] How to round up the result in a cell containing formula
    By Mostropovich in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 10:05 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