tiredofit
Well-known Member
- Joined
- Apr 11, 2013
- Messages
- 1,834
- Office Version
- 365
- 2019
- Platform
- Windows
I want to format some columns on a worksheet using numbers instead of letters.
Both versions of the following code are in a standard module.
This uses letters:
and this uses numbers:
They both work IF Sheet1 is already selected.
However, if Sheet1 is NOT selected, only the one using letters work.
Is there a way to make the numbers version work without the need to select the sheet first?
Thanks
Both versions of the following code are in a standard module.
This uses letters:
Code:
Sheet1.Range("A:A,C:C").NumberFormat = "General"
Sheet1.Range("B:B,D:D").NumberFormat = "0"
Sheet1.Range("E:E").NumberFormat = "#,##0"
and this uses numbers:
Code:
Sheet1.Range(Columns(1), Columns(3)).NumberFormat = "General"
Sheet1.Range(Columns(2), Columns(4)).NumberFormat = "0"
Sheet1.Range(Columns(5), Columns(5)).NumberFormat = "#,##0"
They both work IF Sheet1 is already selected.
However, if Sheet1 is NOT selected, only the one using letters work.
Is there a way to make the numbers version work without the need to select the sheet first?
Thanks