oleg_v
02-16-2010, 06:14 AM
Hello
i have this macro:
Sub ProcessData()
Const TEST_COLUMN As String = "A" '<=== change to suit
Dim i As Integer
Dim LastRow As Long
Dim NextRow As Long
Dim mnth As Integer
With Sheets("sheet1")
mnth = InputBox("Supply the required month number")
If mnth > 0 And mnth <= 12 Then
LastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
NextRow = 5
For i = 6 To LastRow
H = 0
If Month(.Cells(i, "AU").Value) = mnth Then
NextRow = NextRow + 1
.Cells(i, "AV").Resize(, 1).Copy Worksheets("Sheet2").Cells(NextRow, "D")
End If
Next i
End If
End With
End Sub
how can i get it to copy only 30 rows from latest date and up from the same month
thanks
Oleg
i have this macro:
Sub ProcessData()
Const TEST_COLUMN As String = "A" '<=== change to suit
Dim i As Integer
Dim LastRow As Long
Dim NextRow As Long
Dim mnth As Integer
With Sheets("sheet1")
mnth = InputBox("Supply the required month number")
If mnth > 0 And mnth <= 12 Then
LastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
NextRow = 5
For i = 6 To LastRow
H = 0
If Month(.Cells(i, "AU").Value) = mnth Then
NextRow = NextRow + 1
.Cells(i, "AV").Resize(, 1).Copy Worksheets("Sheet2").Cells(NextRow, "D")
End If
Next i
End If
End With
End Sub
how can i get it to copy only 30 rows from latest date and up from the same month
thanks
Oleg