Convert columns formatted as text to number

Dokat

Active Member
Joined
Jan 19, 2015
Messages
304
Office Version
  1. 365
Hi,'

I have a worksheet ("POS") with data table where I'd like to format column F as number. Column F has some text fields (All Other) and numbers formatted as text together. Is there anyway to convert format of the column as numbers. I tried below code however it didn't do anything. Appreciate any help! Thanks

VBA Code:
Sub ConvertToNumber()
Application.ScreenUpdating = False
Worksheets("POS").Columns("F").Select
Selection.NumberFormat = "0"
Application.ScreenUpdating = True
End Sub
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
"and numbers formatted as text together" What does this mean?
You can only convert numericals formatted as text back to numerical values.
Multiply by 1 or use CDbl
 
Upvote 0
If I have understood you correctly, here are 2 ways.

NON VBA WAY

The easiest way to do it is using Data | Text to Columns

1646032017623.png



VBA WAY

VBA Code:
Option Explicit

Sub Sample()
    Dim ws As Worksheet
   
    '~~> Change this to relevant worksheet
    Set ws = Sheet1
   
    With ws
        .Columns(6).TextToColumns Destination:=.Range("F1"), DataType:=xlDelimited, _
        TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
        Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
        :=Array(1, 1), TrailingMinusNumbers:=True
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,744
Members
448,989
Latest member
mariah3

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