Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Formatting and sorting cells with VBA
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).Colu mn 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. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Sorting Cells with Conditional Formatting | Excel Discussion (Misc queries) | |||
Date Formatting & Sorting | Excel Discussion (Misc queries) | |||
Sorting with Formatting | Excel Discussion (Misc queries) | |||
Formatting Date for Sorting | Excel Discussion (Misc queries) | |||
Sorting ListBox results or transposing ListBox values to other cells for sorting | Excel Programming |