anamericangod
New Member
- Joined
- Feb 7, 2014
- Messages
- 5
I am trying to finish a macro by sorting a worksheet by the most recent date. The beginning of the macro takes data from one worksheet (ws1) and pastes it to a new worksheet (ws2) along with a time stamp (=IF($B2<>"",IF(A2="",NOW(),A2),"")) in column A. So column A is filled with formulas that only return a date if there is data in column B, or when it is pasted.
What I want is the macro to finish by sorting that worksheet so that the information is displayed by the most recent date (descending date), but since new data is being added, I need run from a1 through column K of the last row.
I've tried several things, but I can't get anything to work. The most recent thing that I've tried was altered from a thread I found in 2003:
Dim LastRow As Integer
'This is the last non empty row
LastRow = ActiveSheet.UsedRange.Row - 1 + ActiveSheet.Rows.Count
Worksheets("Catchers - Note History").Range("A1:K" &LastRow & ").Sort
Key1:=Worksheets("Catchers - Note History").Columns("A"), Order1:=xlDescending, Header:=xlYes
But that returns an error message. Can anyone help on this?
What I want is the macro to finish by sorting that worksheet so that the information is displayed by the most recent date (descending date), but since new data is being added, I need run from a1 through column K of the last row.
I've tried several things, but I can't get anything to work. The most recent thing that I've tried was altered from a thread I found in 2003:
Dim LastRow As Integer
'This is the last non empty row
LastRow = ActiveSheet.UsedRange.Row - 1 + ActiveSheet.Rows.Count
Worksheets("Catchers - Note History").Range("A1:K" &LastRow & ").Sort
Key1:=Worksheets("Catchers - Note History").Columns("A"), Order1:=xlDescending, Header:=xlYes
But that returns an error message. Can anyone help on this?