1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: Excel Macro needed to only select cells formatted as currency

Discussion in 'Business Applications' started by SasukeSama21, Aug 3, 2010.

Thread Status:
Not open for further replies.
Advertisement
  1. slurpee55

    slurpee55

    Joined:
    Oct 20, 2004
    Messages:
    7,837
    Sasuke, try Application.WorksheetFunction.RoundUp
     
  2. SasukeSama21

    SasukeSama21 Thread Starter

    Joined:
    Aug 3, 2010
    Messages:
    8
    Nope, gave me the same error!

    Thanks
    -SasukeSama21
     
  3. Keebellah

    Keebellah Trusted Advisor

    Joined:
    Mar 27, 2008
    Messages:
    5,946
    Change the code in the module as follows:

    Code:
    
    
    Sub CalcPercentage()
        Dim Cell1 As Range
        For Each Cell1 In Range("A1:H48")
            If IsNumeric(Cell1.Value) = True _
                And Cell1.Value <> "" Then Cell1.Value = Format(Cell1.Value * 1.02, "0.00")
        Next Cell1
    End Sub
    
    
    This will change all numeric cells
     
  4. slurpee55

    slurpee55

    Joined:
    Oct 20, 2004
    Messages:
    7,837
    I figured it was because it was trying to "round" strings - is that what was happening?
     
  5. Keebellah

    Keebellah Trusted Advisor

    Joined:
    Mar 27, 2008
    Messages:
    5,946
    The problem is that the cells in the sample are all formatted G so when the value get's more decimals they expand
     
  6. slurpee55

    slurpee55

    Joined:
    Oct 20, 2004
    Messages:
    7,837
    This may seem dull, but why not just format those specific cells as Number (or Currency!!!) that would be and alter the range to ignore the other cells anyway - then all you would have to deal with is blank cells....
     
  7. SasukeSama21

    SasukeSama21 Thread Starter

    Joined:
    Aug 3, 2010
    Messages:
    8
    The problem is that throughout the entire book, there are cells with words I would have to alter the range specific to each page, and it would take far too long. However Keebellah's last code cuts the numbers to two digits so it works out. I'm going to mark this thread as solved. Thanks for all the help !

    Thanks
    -SasukeSama21
     
  8. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/940456