Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Filter and Move Row Macro

I'm not quite sure how to formulate this macro, any help would be greatly
appreciated. Here is the functionality I am seeking:

1.) Filter column E for entries that are from last month. (current month -
1) (all entries in column E are of format mm/dd/yy hh:mm)
2.) Select those entries and move them to workbook bc-lastmonth.xls
worksheet 'Blood Cultures'
3.) Paste them to the bottom of that worksheet.

This macro would be manually triggered.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Filter and Move Row Macro

This will work

"Luke Slotwinski" wrote:

I'm not quite sure how to formulate this macro, any help would be greatly
appreciated. Here is the functionality I am seeking:

1.) Filter column E for entries that are from last month. (current month -
1) (all entries in column E are of format mm/dd/yy hh:mm)
2.) Select those entries and move them to workbook bc-lastmonth.xls
worksheet 'Blood Cultures'
3.) Paste them to the bottom of that worksheet.

This macro would be manually triggered.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Filter and Move Row Macro

My code didn't get pasted. Here it is again

Sub copylastmonth()

MyMonth = Month(Now())
MyYear = Year(Now())

If MyMonth = 1 Then
MyYear = MyYear - 1
MyMonth = 12
Else
MyMonth = MyMonth - 1
End If

With Workbooks("lastmonth.xls"). _
Worksheets("Blood Cultures")

LastRow = .Cells(Rows.Count, "A"). _
End(xlUp).Row
RowCount = LastRow + 1

LastRowE = Cells(Rows.Count, "E"). _
End(xlUp).Row

Set RowERange = Range(Cells(1, "E"), Cells(LastRowE, "E"))
For Each cell In RowERange

If IsDate(cell) Then
If (Month(cell) = MyMonth) And _
(Year(cell) = MyYear) Then

cell.EntireRow.Copy _
Destination:=.Rows(RowCount & ":" & _
RowCount)
RowCount = RowCount + 1
End If

End If
Next cell
End With

End Sub


"Joel" wrote:

This will work

"Luke Slotwinski" wrote:

I'm not quite sure how to formulate this macro, any help would be greatly
appreciated. Here is the functionality I am seeking:

1.) Filter column E for entries that are from last month. (current month -
1) (all entries in column E are of format mm/dd/yy hh:mm)
2.) Select those entries and move them to workbook bc-lastmonth.xls
worksheet 'Blood Cultures'
3.) Paste them to the bottom of that worksheet.

This macro would be manually triggered.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Filter and Move Row Macro

Thank you Joel, that worked perfectly.
Luke Slotwinski

"Joel" wrote:

My code didn't get pasted. Here it is again

Sub copylastmonth()

MyMonth = Month(Now())
MyYear = Year(Now())

If MyMonth = 1 Then
MyYear = MyYear - 1
MyMonth = 12
Else
MyMonth = MyMonth - 1
End If

With Workbooks("lastmonth.xls"). _
Worksheets("Blood Cultures")

LastRow = .Cells(Rows.Count, "A"). _
End(xlUp).Row
RowCount = LastRow + 1

LastRowE = Cells(Rows.Count, "E"). _
End(xlUp).Row

Set RowERange = Range(Cells(1, "E"), Cells(LastRowE, "E"))
For Each cell In RowERange

If IsDate(cell) Then
If (Month(cell) = MyMonth) And _
(Year(cell) = MyYear) Then

cell.EntireRow.Copy _
Destination:=.Rows(RowCount & ":" & _
RowCount)
RowCount = RowCount + 1
End If

End If
Next cell
End With

End Sub


"Joel" wrote:

This will work

"Luke Slotwinski" wrote:

I'm not quite sure how to formulate this macro, any help would be greatly
appreciated. Here is the functionality I am seeking:

1.) Filter column E for entries that are from last month. (current month -
1) (all entries in column E are of format mm/dd/yy hh:mm)
2.) Select those entries and move them to workbook bc-lastmonth.xls
worksheet 'Blood Cultures'
3.) Paste them to the bottom of that worksheet.

This macro would be manually triggered.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Filter and Move Row Macro

Two Quick questions:
Could I replace the command cell.EntireRow.Copy _ with cell.EntireRow.Cut _
to cut the line and paste it in the lastmonth.xls?

"Joel" wrote:

My code didn't get pasted. Here it is again

Sub copylastmonth()

MyMonth = Month(Now())
MyYear = Year(Now())

If MyMonth = 1 Then
MyYear = MyYear - 1
MyMonth = 12
Else
MyMonth = MyMonth - 1
End If

With Workbooks("lastmonth.xls"). _
Worksheets("Blood Cultures")

LastRow = .Cells(Rows.Count, "A"). _
End(xlUp).Row
RowCount = LastRow + 1

LastRowE = Cells(Rows.Count, "E"). _
End(xlUp).Row

Set RowERange = Range(Cells(1, "E"), Cells(LastRowE, "E"))
For Each cell In RowERange

If IsDate(cell) Then
If (Month(cell) = MyMonth) And _
(Year(cell) = MyYear) Then

cell.EntireRow.Copy _
Destination:=.Rows(RowCount & ":" & _
RowCount)
RowCount = RowCount + 1
End If

End If
Next cell
End With

End Sub


"Joel" wrote:

This will work

"Luke Slotwinski" wrote:

I'm not quite sure how to formulate this macro, any help would be greatly
appreciated. Here is the functionality I am seeking:

1.) Filter column E for entries that are from last month. (current month -
1) (all entries in column E are of format mm/dd/yy hh:mm)
2.) Select those entries and move them to workbook bc-lastmonth.xls
worksheet 'Blood Cultures'
3.) Paste them to the bottom of that worksheet.

This macro would be manually triggered.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Advanced Filter: How do you MOVE the selected rows... ravif Excel Worksheet Functions 3 June 29th 09 10:25 PM
Need macro to filter, create tab on filter and copy/paste Jen[_11_] Excel Programming 1 May 2nd 06 04:45 PM
Need macro to filter, create tab on filter and copy/paste Jen[_11_] Excel Programming 1 May 2nd 06 04:45 PM
move data to a single cell and at the same same time filter the da Ann Excel Discussion (Misc queries) 1 April 4th 05 02:47 PM
After Filter - Move to first cell Tempy Excel Programming 4 July 3rd 04 04:09 AM


All times are GMT +1. The time now is 06:43 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"