Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VBA format cells to General

I would like to format a excel file to "General", but it's not working for all cells (some are custom, pourcentage...). 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:="|"

help please.

like image 645
BKChedlia Avatar asked Jun 19 '16 13:06

BKChedlia


People also ask

How do I change the format of a column in Excel VBA?

Highlight a cell in the left column of your table. On the Home section of the ribbon, click Conditional Formatting , then New Rule . Use a formula to determine which cells to format . Click Format and set Number to Currency , then click OK.


1 Answers

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

Sub dural()
    ActiveSheet.Cells.NumberFormat = "General"
End Sub
like image 91
Gary's Student Avatar answered Sep 22 '22 03:09

Gary's Student