+ Reply to Thread
Results 1 to 4 of 4

VBA to Multiply all numbers formatted as a currency by a cell value

  1. #1
    Registered User
    Join Date
    09-03-2013
    Location
    Munich, Germany
    MS-Off Ver
    Excel 2010
    Posts
    4

    VBA to Multiply all numbers formatted as a currency by a cell value

    Hello,

    I have a workbook where I'd like to change the currencies between USD & Euro (and back again) easily.

    I'm able to find and change a currency format however I'm not able to identify just those numbers that are a currency and multiply by a value in [A1] (for the exchange rate).

    So, I can change $10 to €10 but what I need to do is change $10 to €9.40 based on the exchange rate 0.94$ in cell [A1].

    Any help would be greatly appreciated.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,962

    Re: VBA to Multiply all numbers formatted as a currency by a cell value

    I think you also need to fully identify the cell - [A1] refers to the activesheet, which may or may not have the correct value, and change the format as you change the value:

    Sub CurrencyConvert2()
    Dim theSheet As Worksheet
    Dim c As Range
    Dim dRate As Double

    dRate = Worksheets("Sheet1").Range("A1").Value

    For Each theSheet In ActiveWorkbook.Sheets
    For Each c In theSheet.UsedRange
    If Left(c.Text, 1) = "$" Then
    c.Value = c.Value * dRate
    c.NumberFormat = "[$€-x-euro2] #,##0.00"
    End If
    Next c
    Next theSheet
    End Sub
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,962

    Re: VBA to Multiply all numbers formatted as a currency by a cell value

    Sorry - I forgot to wrap my code in tags, and now I cannot edit it.....

  4. #4
    Registered User
    Join Date
    09-03-2013
    Location
    Munich, Germany
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: VBA to Multiply all numbers formatted as a currency by a cell value

    Hi Bernie,

    Works an absolute treat! Many thanks - this has been driving me crazy for a couple of days.

    Cheers :-)

+ 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] Show currency formatted numbers as a result from a StringConcat code
    By score in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-12-2016, 09:22 PM
  2. [SOLVED] formatted cell for general, changes to currency
    By survivo in forum Excel General
    Replies: 2
    Last Post: 07-19-2014, 04:42 PM
  3. How to get the actual cell value of a currency formatted cell
    By hasanahmad in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-30-2013, 12:08 PM
  4. To calculate/sum all numbers that are formatted in currency?
    By Dwexdwex in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-12-2013, 01:14 AM
  5. [SOLVED] multiply time and currency
    By Janelle in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 03-26-2006, 06:45 PM
  6. Multiply currency
    By sorrywm in forum Excel General
    Replies: 5
    Last Post: 12-22-2005, 11:00 AM
  7. Multiply Time by currency
    By Strelak in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-17-2005, 11:56 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