BKChedlia
BKChedlia

Reputation: 337

VBA format cells to General

I would like to format an Excel file to "General", but it's not working for all cells (some are custom, percentage...).

Here is my code:

With ActiveSheet.Range("A1").Resize(LineIndex, 1)
    .Value = WorksheetFunction.Transpose(strLine)
    .NumberFormat = "General"
    'DEFINE THE OPERATION FULLY!!!!
    .TextToColumns Destination:=.Cells(1), DataType:=xlDelimited, _
                   TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, _
                   Tab:=False, Semicolon:=False, Comma:=False, Space:=False, _
                   Other:=True, OtherChar:="|"
End With

Upvotes: 8

Views: 75002

Answers (1)

Gary's Student
Gary's Student

Reputation: 96753

If you want to format all cells to General, then use something like:

Sub dural()
    ActiveSheet.Cells.NumberFormat = "General"
End Sub

Upvotes: 24

Related Questions