ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Number Format Code won't work (https://www.excelbanter.com/excel-discussion-misc-queries/161950-number-format-code-wont-work.html)

tbmarlie

Number Format Code won't work
 
I have the following code to try to format two columns of numbers into
numeric format, but it doesn't want to work. There are blanks within
the 2 columns; otherwise I would just do a selec-end-down. Thanks.

Dim LastRow As Long
LastRow = Cells(Rows.Count, "G").End(xlUp).Row
Range("J2" & LastRow).NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Range("K2" & LastRow).NumberFormat = "#,##0.00_);[Red](#,##0.00)"

Here's my sample data:

Column J Column K
Adjustment YTD Changes
6,550.63
6,550.63
1,984.62
1,984.62
-10,408.46
-10,408.46
13,350.04
13,350.04
4,118.37
4,118.37
-3,213.00
31.5
-6


Gary''s Student

Number Format Code won't work
 
You have only a very small error:

Range("J2:J" & LastRow).NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Range("K2:K" & LastRow).NumberFormat = "#,##0.00_);[Red](#,##0.00)"

this "fills out" the range. Make sure column G goes down far enough

--
Gary''s Student - gsnu2007


"tbmarlie" wrote:

I have the following code to try to format two columns of numbers into
numeric format, but it doesn't want to work. There are blanks within
the 2 columns; otherwise I would just do a selec-end-down. Thanks.

Dim LastRow As Long
LastRow = Cells(Rows.Count, "G").End(xlUp).Row
Range("J2" & LastRow).NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Range("K2" & LastRow).NumberFormat = "#,##0.00_);[Red](#,##0.00)"

Here's my sample data:

Column J Column K
Adjustment YTD Changes
6,550.63
6,550.63
1,984.62
1,984.62
-10,408.46
-10,408.46
13,350.04
13,350.04
4,118.37
4,118.37
-3,213.00
31.5
-6



tbmarlie

Number Format Code won't work
 
On Oct 12, 4:36 pm, Gary''s Student
wrote:
You have only a very small error:

Range("J2:J" & LastRow).NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Range("K2:K" & LastRow).NumberFormat = "#,##0.00_);[Red](#,##0.00)"

this "fills out" the range. Make sure column G goes down far enough

--
Gary''s Student - gsnu2007



"tbmarlie" wrote:
I have the following code to try to format two columns of numbers into
numeric format, but it doesn't want to work. There are blanks within
the 2 columns; otherwise I would just do a selec-end-down. Thanks.


Dim LastRow As Long
LastRow = Cells(Rows.Count, "G").End(xlUp).Row
Range("J2" & LastRow).NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Range("K2" & LastRow).NumberFormat = "#,##0.00_);[Red](#,##0.00)"


Here's my sample data:


Column J Column K
Adjustment YTD Changes
6,550.63
6,550.63
1,984.62
1,984.62
-10,408.46
-10,408.46
13,350.04
13,350.04
4,118.37
4,118.37
-3,213.00
31.5
-6- Hide quoted text -


- Show quoted text -


Thanks, Gary. That did the job.



All times are GMT +1. The time now is 03:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com