Text to Number format

syedjaveed

New Member
Joined
Feb 28, 2013
Messages
37
Hi Team

I want to convert the numbers in a column A and B from text format to number format with the help of vba...kindly help
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Hi,
Here is the script to change to number format. I use it regularly.
Instructions
1. When open in excel ALT + F11
2. Double click This Workbook
3. Copy the below script and paste
4. Select the column you want to change to number format
5. Return to the code and ensure you have selected the correct sheet
6. Once you are happy press F5 to execute
7. Done you can now close the VB code screen.
8. NB always ensure you have a backup of the excel file before running any script as it will not any undo function.

VB Script
Sub Txt_to_No()
'
' To change text format to number format
'
For P = 1 To Sheets.Count 'Change here for the sheet number P = n
Sheets(P).Activate

Selection.TextToColumns Destination:=Selection, DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
:=Array(1, 1), TrailingMinusNumbers:=True
Selection.NumberFormat = "0" 'Here you can select the type of format. Currently set to normal number format
Exit Sub
Next
End Sub

<tbody>
</tbody>
 
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,313
Members
452,634
Latest member
cpostell

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