+ Reply to Thread
Results 1 to 15 of 15

change currency formatting based on value of another cell

  1. #1
    Registered User
    Join Date
    01-06-2010
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    7

    change currency formatting based on value of another cell

    Hello,
    I have a conditional formatting issue in Excel 2007.

    I have a drop down list which shows 4 countries; UK, DE, FR and NL

    I would like to change the format of a number of cells to £ or € dependent on what the dropdown box has chosen.

    I have a number of vlookups, so it pulls the right amount, and the right SKU, but I cannot get it to change the formatting correctly. I have even tried to simplify it to say, if UK use £ and if <> UK then use €, but that doesn't change either. If I change it, so it colours red for UK, and clear for not UK, that works.

    Can anyone help please?
    Thanks, 17ND

    Configuration: Windows 7 x64/Excel 2007 SP2/Dell Latitude E4300
    Last edited by 17ND; 01-11-2010 at 06:09 PM. Reason: [SOLVED]

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: change currency formatting based on value of another cell

    Click GO ADVANCED and use the paperclip icon to post up your workbook. Make sure the cells you're wanting help with are evident.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    01-06-2010
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: change currency formatting based on value of another cell

    As per post request:
    Hardware tab; change the dropdown in A1, should change the entries in cells K114:L141
    Thanks for the help!
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    01-06-2010
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: change currency formatting based on value of another cell

    The issue is that although the values change, I cannot get it to change the formatting from £ to € consistently.

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: change currency formatting based on value of another cell

    1) open up the hardware sheet module and remove the code that is in there
    2) paste in this instead:
    Please Login or Register  to view this content.
    3) Close the editor and save your sheet.

    Now any changes to cell A1 will trigger the reformatting.

  6. #6
    Registered User
    Join Date
    01-06-2010
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: change currency formatting based on value of another cell

    Hey, thanks for that, I really appreciate the help.

    I have one small glitch though - at first it didn't appear to work, but if I delete the value in A1, and then select again from the dropdown list, it works every time. What would I need to do to the code to change it so I don't need to have nothing in the cell in order to be able to successfully select the currency?

    Thanks again though for the help so far, (I don't mean to sound unappreciative) - I have been scratching my head for a couple of days to get it working!

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: change currency formatting based on value of another cell

    I don't see the problem you're seeing. I do see a problem with your formulas, this would make them not show errors and evaluate the currency type faster:

    K114: =IF($A$1="","",VLOOKUP($C114,vLookupSW!$A$2:$M$30,LOOKUP($A$1,{"DE","FR","NL","UK"},{11,11,11,9}),0))

    L114: =IF($A$1="","",VLOOKUP($C114,vLookupSW!$A$2:$M$30,LOOKUP($A$1,{"DE","FR","NL","UK"},{10,10,10,8}),0))

    Copied down, this appears to make the sheet appear to function more smoothly. I can see no error with macro itself. Removing the value in A1 would cause the macro to do nothing, so the corrected formulas above might resolve your perceived issue.

    The LOOKUP() formulas are alphabetical, and you could actually shorten them down to:
    =IF($A$1="","",VLOOKUP($C114,vLookupSW!$A$2:$M$30,LOOKUP($A$1,{"DE","UK"},{11,9}),0))

    ...but I thought it might be confusing to not see the FR and NL values listed, even though they aren't needed since they are the same value as DE.
    Attached Files Attached Files
    Last edited by JBeaucaire; 01-07-2010 at 02:02 PM.

  8. #8
    Registered User
    Join Date
    01-06-2010
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: change currency formatting based on value of another cell

    Hi JBeaucaire
    Sorry for the delay in replying, I had to take the sheet and try to tidy it up a little.

    I have implemented the revised (more efficient formulas - thank you!), and everything seems to be working well, except, if you choose UK, then choose DE, FR or NL, it does indeed set the currency to Euros, but if you then choose UK, it won't revert back to £. It seems to stick on Euros.

    I have uploaded the workbook again, and wonder if you would mind taking another look to see where I have gone wrong?

    All choices are set on the options tab. The only issue is for the country to currency correlation. All the hardware lookups, (on configuration tab, rows 10-113) do a vlookup on vLookupHW and all the software lookups, (on configuration tab, rows 120-147) do a vlookup on vLookupSW.

    Let me know if I need to explain anything else.

    Many thanks again, 17ND.
    Attached Files Attached Files

  9. #9
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: change currency formatting based on value of another cell

    Why did you move the sheet macro into a regular module? That will never work. A worksheet_???? macro always goes into the worksheet where it is supposed to "work". Macros placed in regular modules have to be manually activated or called from other macros.

    Since you also changed the currency selection to the Options page, the macro will have to be rewritten to reside in one sheet (Options) but make changes to another sheet when triggered. These are substantive changes.

    The macro requires you watch a specific cell, that's why my posted macro watched cell [A1] as you had requested. When you moved it, you also edited it to take out that watch, so the macro has not target any longer specified. You can't do that.

    Please Login or Register  to view this content.
    ...this is meaningless for this macro, we need to be checking the target address. It now needs to be [B1] on the Options sheet.

    Lastly, you moved the columns AND rows for this macro to change. These are truly important changes. You have to update your macros if you're not done fiddling with your sheet design.

    Remove the other macro. Put this in the OPTIONS sheet module.
    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 01-08-2010 at 04:48 PM.

  10. #10
    Registered User
    Join Date
    01-06-2010
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: change currency formatting based on value of another cell

    Hi JB
    Apologies, I was getting confused myself.

    I have done as you said, and removed the other macro, and placed your code in the Options sheet module, but whilst it will format UK £s, it won't do the €s?

    I don't get why, reading your code? Have uploaded the sheet with the macro in place...

    Would you mind taking a look and seeing if I have made a mistake somewhere?

    Thanks, ND
    Attached Files Attached Files

  11. #11
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: change currency formatting based on value of another cell

    It's working for me, though I want to be sure, you aren't trying to change the value in A1 on "Configuration" are you? I noticed you put the validation list back...that will confuse someone into thinking they CAN change it there. I took it out and put the =Options!B1 formula back in there.

    It's simple...whatever sheet you are making the cell change in manually, that's the sheet that gets the worksheet_change macro customized for what's going on on THAT sheet. OK?

    Works for me.
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    01-06-2010
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: change currency formatting based on value of another cell

    Bizarrely, that works for me? Is that the same workbook I uploaded earlier today?

    The only place I change the country now, is on the Options tab. It should tell you on the Configuration tab, in A1, what country is reflected, but there is no need to have validation there too, that was just from before.

    I will go ahead and continue with the rest of the sheet, but that shouldn't have anything that might upset the macro now.

    Really appreciate the help, thank you very much!

  13. #13
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: change currency formatting based on value of another cell

    If that takes care of your need, be sure to EDIT your original post, click Go Advanced and mark the PREFIX box [SOLVED].


    (Also, use the blue "scales" icon in our posts to leave Reputation Feedback, it is appreciated. It is found across from the "time" in each of our posts.)

  14. #14
    Registered User
    Join Date
    05-11-2009
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: change currency formatting based on value of another cell

    I have a very similar issue to the one above but unfortunately I dont have any programming experience so Im finding it a little hard to tailor the code above to my workbook.
    Basically I want the currency symbol to change between $ and ¥ in cells U32:u40 and Q32:Q34 in Quotation! worksheet depending on whether the value of summary!d6 is Australian dollars or Japanese Yen.
    Im not even sure whether to put the code in the summary or quotation worksheet.

    Hope you can help.
    Attached Files Attached Files

  15. #15
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: change currency formatting based on value of another cell

    shaunnehughes, please take a look at the forum rules and then start your own thread.

    thanks.

+ 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