0

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?

googlesheet test
  • 247
  • 1
  • 13
  • Remove `[E:E].Select`, then change `With Selection` to `With ThisWorkbook.Worksheets("Yoursheetname").Range("E:E")` – BigBen Oct 19 '22 at 14:36

1 Answers1

1

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

Ike
  • 9,580
  • 4
  • 13
  • 29