Dynamic Number Formats in Code Based on Cell Value

John_356

New Member
Joined
Jan 17, 2021
Messages
26
Office Version
  1. 365
Platform
  1. Windows
Good day,

I'm building an automated tool for management/follow up/reporting purposes.
The company I'm managing from a distance is based in the Middle East and they have a different NumberFormat there, for example 2 000,00 i/o 2 000.00 - the difference being the "," and "." for decimal values.

For each formula my code defines a format, as per below example:

VBA Code:
Worksheets("S").Range("K2").Formula = "=IF(A2=A1,"""",IFNA(VLOOKUP($A2&"":""&K$1,T!$C:$J,8,FALSE),""""))"
Worksheets("S").Range("K2").AutoFill Worksheets("S").Range("K2:K" & LRS)
Worksheets("S").Columns("K"). _
NumberFormat = "#,##0.00_);[Red](#,##0.00)"

I would like to edit the last lane about the NumberFormat with an IF function based on a cell which will define the format; I'm thinking of a two item list like USA or Middle East with a title that says NumberFormat.

Should the information I've provided not sufficient please do not hesitate to ask.

Many thanks in advance for anybody who will spend any time on this regardless of success.

John
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Forum statistics

Threads
1,215,046
Messages
6,122,849
Members
449,096
Latest member
Erald

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