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 05:09 PM. Reason: [SOLVED]
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 theicon 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!)
As per post request:
Hardware tab; change the dropdown in A1, should change the entries in cells K114:L141
Thanks for the help!
The issue is that although the values change, I cannot get it to change the formatting from £ to € consistently.
1) open up the hardware sheet module and remove the code that is in there
2) paste in this instead:
3) Close the editor and save your sheet.Private Sub Worksheet_Change(ByVal Target As Range) If Target.Count > 1 Then Exit Sub If Not Intersect(Target, [A1]) Is Nothing Then Set RNG = Range("K114:L141") Select Case Target Case "UK" RNG.NumberFormat = "[$£-809]#,##0.00;[Red]-[$£-809]#,##0.00" Case Else RNG.NumberFormat = "#,##0.00 [$€-1];[Red]-#,##0.00 [$€-1]" End Select End If End Sub
Now any changes to cell A1 will trigger the reformatting.
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon 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!)
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!
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.
Last edited by JBeaucaire; 01-07-2010 at 01:02 PM.
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon 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!)
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.
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.
...this is meaningless for this macro, we need to be checking the target address. It now needs to be [B1] on the Options sheet.If Target.Count = 1 Then
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.
Private Sub Worksheet_Change(ByVal Target As Range) If Target.Count > 1 Then Exit Sub If Target.Address = "$B$1" Then Set Rng = Sheets("Configuration").Range("I120:J147") Select Case Target Case "UK" Rng.NumberFormat = "[$£-809]#,##0.00;[Red]-[$£-809]#,##0.00" Case "DE", "FR", "NL" Rng.NumberFormat = "#,##0.00 [$€-1];[Red]-#,##0.00 [$€-1]" Case Else Rng.NumberFormat = "#,##0.00 ;[Red]-#,##0.00" End Select End If End Sub
Last edited by JBeaucaire; 01-08-2010 at 03:48 PM.
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon 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!)
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
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.
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon 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!)
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!
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.)
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon 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!)
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.
shaunnehughes, please take a look at the forum rules and then start your own thread.
thanks.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks