+ Reply to Thread
Results 1 to 5 of 5

How to change the number of decimal places in a variable cell reference...

Hybrid View

  1. #1
    Registered User
    Join Date
    01-11-2010
    Location
    tracy, ca
    MS-Off Ver
    Excel 2003
    Posts
    39

    How to change the number of decimal places in a variable cell reference...

    I feel like an idiot for not being able to figure this out. I want to change the number of decimal places to 2 for a few cell references. My code:

    
    Round(Range("B:" & (q + 2)).Value, 2)
    It's telling me it expects an = sign. What am I doing wrong?

    Considering the complexity of my macro I can't even figure out something as simple as this.

    Thanks for your help!
    Last edited by kenab1; 03-08-2010 at 01:32 PM.

  2. #2
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: How to change the number of decimal places in a variable cell reference...

    Try this
       somevar = Round(Range("B:" & (q + 2)).Value, 2)

  3. #3
    Registered User
    Join Date
    01-11-2010
    Location
    tracy, ca
    MS-Off Ver
    Excel 2003
    Posts
    39

    Re: How to change the number of decimal places in a variable cell reference...

    Ok got rid of the = sign issue but it's still giving me an error at that point. Thanks though.

  4. #4
    Registered User
    Join Date
    01-11-2010
    Location
    tracy, ca
    MS-Off Ver
    Excel 2003
    Posts
    39

    Re: How to change the number of decimal places in a variable cell reference...

    Ok I figured out a way to do it. The following code:

        somevar = Cells(q + 2, 2).Value
        r1 = Round(somevar, 2)
        Cells(q + 2, 2).Value = r1
    It's Monday morning. Brain no worky.

  5. #5
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: How to change the number of decimal places in a variable cell reference...

    Just noticed
    somevar = Round(Range("B:" & (q + 2)).Value, 2)
    Try
    somevar = Round(Range("B" & (q + 2)).Value, 2)
    Delete ":"

    sorry I missed that first time round

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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