N
news.sf.sbcglobal.net
I need to apply date formatting to column A and then sort the entire
worksheet by column A ascending. I don't know how many rows/columns there
will be, but row 1 is always the header row.
I calculate the last row and column like this:
lc = .Range("A1").SpecialCells(xlCellTypeLastCell).Column
lr = .Range("A1").SpecialCells(xlCellTypeLastCell).Row
(no problem using SpecialCells here)
I've tried the following VBA code, but no luck:
With xlapp.Workbooks(strXlsFile).Worksheets(sn(i))
.Range("A2:A" & lr).NumberFormat = "mm/dd/yyyy hh:mm;@"
End with
With xlapp.Workbooks(strXlsFile).Worksheets(sn(i))
.Range(.Cells(2, 1), .Cells(lr, lc)).NumberFormat = "mm/dd/yyyy hh:mm;@"
End with
Why is this not working? The macro recorder returns this:
Range("A2:A106").Select
Selection.NumberFormat = "mm/dd/yyyy hh:mm;@"
Do I need to select the range in VBA??
Thanks in advance.
worksheet by column A ascending. I don't know how many rows/columns there
will be, but row 1 is always the header row.
I calculate the last row and column like this:
lc = .Range("A1").SpecialCells(xlCellTypeLastCell).Column
lr = .Range("A1").SpecialCells(xlCellTypeLastCell).Row
(no problem using SpecialCells here)
I've tried the following VBA code, but no luck:
With xlapp.Workbooks(strXlsFile).Worksheets(sn(i))
.Range("A2:A" & lr).NumberFormat = "mm/dd/yyyy hh:mm;@"
End with
With xlapp.Workbooks(strXlsFile).Worksheets(sn(i))
.Range(.Cells(2, 1), .Cells(lr, lc)).NumberFormat = "mm/dd/yyyy hh:mm;@"
End with
Why is this not working? The macro recorder returns this:
Range("A2:A106").Select
Selection.NumberFormat = "mm/dd/yyyy hh:mm;@"
Do I need to select the range in VBA??
Thanks in advance.