Macro help please!

eddy

Well-known Member
Joined
Mar 2, 2002
Messages
521
I need a macro which will format cells H21 to H34 and I35 TO I38 to either Sterling £(2 decimal Places) or Dollar $(2 decimalplaces).
To be triggered by a Question or maybe tick Boxes.

All help most appreciated.

Regards Ed
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Try

Code:
Sub test()
If MsgBox("£", vbYesNo + vbQuestion) = vbYes Then
    Range("H21:H34,I35:I38").NumberFormat = "$#,##0.00"
Else
    Range("H21:H34,I35:I38").NumberFormat = "[$$-409]#,##0.00"
End If
End Sub
 
Upvote 0
This works a treat many thanks for your help.
Much appreciated.
Just as a matter of interest. Could this formatting be automatically triggered by the entry in Cell E13.
e.g If Cell E13 = Andrel Electronics or Cardel Elecronics then format the ranges in $ ELSE format in £

Regards Ed
 
Upvote 0
Try

Code:
Sub test()
If Range("E13").Value = "Andrel Electronics" Or Range("E13").Value = "Cardel Elecronics" Then
    Range("H21:H34,I35:I38").NumberFormat = "[$$-409]#,##0.00"
Else
    Range("H21:H34,I35:I38").NumberFormat = "$#,##0.00"
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,482
Messages
6,113,913
Members
448,532
Latest member
9Kimo3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top