Converting a column of text to number with macro

JohnSeito

Active Member
Joined
Nov 19, 2007
Messages
390
Hi

Could someone show me a code that would convert a column of text to number with macro.

Thanks appreciate it.
 

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"
No need to select individual columns, just drop the code and run it.

Sub Convert_to_number()<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
'<o:p></o:p>
' Convert_to_number()<o:p></o:p>
'<o:p></o:p>
<o:p> </o:p>
'<o:p></o:p>
Application.ScreenUpdating = False<o:p></o:p>
ActiveCell.SpecialCells(xlLastCell).Select<o:p></o:p>
Range(Selection, Cells(1)).Select<o:p></o:p>
Selection.Value = Selection.Value<o:p></o:p>
Range("A1").Select<o:p></o:p>
End Sub<o:p></o:p>
 
Upvote 0
Hi @ronahaim,

Could you please explain further what you are attempting to do and whether or not you want a formula, a user-defined function or a macro. Converting text to numbers can be done is many different ways.

Good luck.

AMAS
 
Upvote 0
i want to write a function in vba

need to fill the " ?????????"

Public Function ColumnLetters(ByVal ColNum As Integer) As String
If ColNum > 26 And ColNum < 703 Then
ColumnLetters = Chr(Int((ColNum - 1) / 26) + 64) & Chr(((ColNum - 1) Mod 26) + 65)
End If
If ColNum <= 26 Then
ColumnLetters = Chr(ColNum + 64)
End If
If ColNum >= 703 Then
?????????
End If

end function



Thanks !!!!!
 
Upvote 0
Highlight the Cells that you wish to convert and run this Macro

Sub Foo()
Set Rng = Selection
For Each c In Rng
With Rng
c.Value = c.Value + 0
End With
Next c
End Sub


What if you want to apply this to all sheets except for a couple of sheets only in the range of A2:A100 ?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,614
Messages
6,120,519
Members
448,968
Latest member
Ajax40

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