vba - my code changes my number formatting to number, but I still get the exclamation saying number formatted as text.

parkerbelt

Active Member
Joined
May 23, 2014
Messages
377
I have the following code that changes my number formatting to number, when it started as text, but after the program runs, I still have the exclamation point and the green box in the upper left corner of the cells that says numbers formatted as text. Is there a way to get that to stop happening? When I right click and check the number formatting after the program runs, it says that it is a number with zero decimal places, but I'm getting the message still.

Code:
Application.Calculation = xlManual
    Range("C26").Select
    Range(Selection, Selection.End(xlDown)).Select


    Selection.NumberFormat = "0"
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
It is not enough simply change the cell format if they were entered as text. You need to re-enter the values.
Here is one way:
Code:
    Dim lastRow As Long
    lastRow = Range("C26").End(xlDown).Row
    Range("C26:C" & lastRow).NumberFormat = "0"
    [COLOR=#ff0000]Range("C26:C" & lastRow).Value = Range("C26:C" & lastRow).Value[/COLOR]
 
Last edited:
Upvote 0
Another method would be to copy a blank cell and then do a paste special add.
Code:
Cells(Rows.Count, Columns.Count).Copy

Range("C26:C" & Range("C" & Rows.Count).End(xlUp).Row).PasteSpecial Operation:=xlPasteSpecialOperationAdd
 
Upvote 0
That worked! Thank you Sir!!

It is not enough simply change the cell format if they were entered as text. You need to re-enter the values.
Here is one way:
Code:
    Dim lastRow As Long
    lastRow = Range("C26").End(xlDown).Row
    Range("C26:C" & lastRow).NumberFormat = "0"
    [COLOR=#ff0000]Range("C26:C" & lastRow).Value = Range("C26:C" & lastRow).Value[/COLOR]
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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