+ Reply to Thread
Results 1 to 9 of 9

Divide two double type data in VBA with keeping the formula

  1. #1
    Registered User
    Join Date
    06-29-2014
    Location
    Budapest, Hungary
    MS-Off Ver
    2010
    Posts
    4

    Exclamation Divide two double type data in VBA with keeping the formula

    DA,

    I have a question with the following problem.
    I would like to divide two numbers (stored as Double), but also would like to keep them separately in the cell, so when you select the cell you can see: "=12,33/1,2342" (example)

    Please Login or Register  to view this content.
    Thank you for your help in advance.


    BR,
    Daniel

  2. #2
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Divide two double type data in VBA with keeping the formula

    Have you tried changing the + to an &

    From this

    T4BCell.Value = "=" & T4ANumerator + "/" & T4ADominator

    To this

    T4BCell.Value = "=" & T4ANumerator & "/" & T4ADominator

  3. #3
    Forum Expert Tsjallie's Avatar
    Join Date
    09-15-2012
    Location
    NL
    MS-Off Ver
    2010, 2013, 2016
    Posts
    2,077

    Re: Divide two double type data in VBA with keeping the formula

    If you replace the + by & and remove the = it should work fine.
    But remember that the content of the cell will be text and no longer be double.
    You cannot put more than one value in a cell.
    Cheers!
    Tsjallie




    --------
    If your problem is solved, pls mark the thread SOLVED (see Thread Tools in the menu above). Thank you!

    If you think design is an expensive waste of time, try doing without ...

  4. #4
    Registered User
    Join Date
    06-29-2014
    Location
    Budapest, Hungary
    MS-Off Ver
    2010
    Posts
    4

    Re: Divide two double type data in VBA with keeping the formula

    Hi Crooza,

    Yes, I've tried (actually I started with that one), but later I chose to try everything I could, but nothing helped me .

    I tried:
    - change double data type to string
    - change double to integer (in that case it worked, but integer doesn't have decimal, therefore it wasn't good for me)

    My guess is that the problem is behind the decimals so I tried to convert the decimal from "," to ".", but this wasn't good either.

  5. #5
    Registered User
    Join Date
    06-29-2014
    Location
    Budapest, Hungary
    MS-Off Ver
    2010
    Posts
    4

    Re: Divide two double type data in VBA with keeping the formula

    You are right, it worked w/o the "=".

    However what I received now is not good for me either.

    What I need in the cell:
    e.g.: 2
    What I need in the function field when I click on the field is: =6,5/3,25

  6. #6
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Divide two double type data in VBA with keeping the formula

    This code works. puts the =6.5/3.25 in the cell(and the formula bar) but the cell displays 2

    Please Login or Register  to view this content.

  7. #7
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Divide two double type data in VBA with keeping the formula

    here you go this should work for you


    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    06-29-2014
    Location
    Budapest, Hungary
    MS-Off Ver
    2010
    Posts
    4

    Re: Divide two double type data in VBA with keeping the formula

    Crooza, U R awesome

    This helped a lot.

    Note:
    I needed to extend this to work with the following due to the decimal separator differences:
    Please Login or Register  to view this content.
    Thank you once again.

    BR,
    Daniel

  9. #9
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Divide two double type data in VBA with keeping the formula

    Great. Glad it worked. Don't forget to mark it as SOLVED
    Last edited by Crooza; 06-29-2014 at 05:56 AM.

+ 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] Not of Double Type but within Double Type Range?
    By exceltabz in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-09-2014, 09:30 AM
  2. Replies: 0
    Last Post: 09-03-2013, 11:26 AM
  3. Keeping the First and Last Row of a Specific Cell Type in a Column
    By maliotta in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 07-12-2013, 10:26 AM
  4. convert textbox value from string to either single or double numeric data type
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-08-2011, 06:40 PM
  5. Trying to design a double entry book-keeping ledger i need some help!
    By Brian cook in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-28-2006, 08:23 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