I am using a code I found in another thread to convert a column from text to number:
[E:E].Select
With Selection
.NumberFormat = "General"
.Value = .Value
End With
This runs in the current tab/sheet I am currently in but my workbook has several tabs and I only want it to run in one sheet. What would I need to add to the code to only run in one specified sheet?
CodePudding user response:
You can use this code:
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("XXXX") '--> insert your sheets name
Dim rg As Range
Set rg = ws.Range("E:E")
With rg
.NumberFormat = "General"
.Value = .Value
End With
Select is not needed - maybe this is interesting for you How to avoid select
CodePudding user response:
The correct code you need for this is:
Sub Macro ()
Sheets("Sheet1").Columns("E:E").NumberFormat = "General"
End Sub
Where you specify the sheet and the columns, this is for general in case you want numbers the .NumberFormat would be: "0.00"