Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi all,
I have a "master" spreadsheet and 3 other spreadsheets "Month","Vic", "Day" all in the same workbook. how can i create a macro that go through the "master" sheet and look at column D and E (in the same row) to find certain conditions: if column D has "MVInd" and column E has the letter "M", then copy that row to the spreadsheet "Month" if column D has "COD" and column E has the letter "V", then copy that row to the spreadsheet "Vic" if column D has "OPTD" and column E has the letter "D", then copy that row the spreadsheet "Day" the macro should keep doing that until there is a blank row in the "master" sheet. Thank you very much. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub test()
MonthRowCount = 1 VicRowCount = 1 DayRowCount = 1 RowCount = 1 With Sheets("Master") Do While .Range("D" & RowCount) < "" If .Range("D" & RowCount) = "MVInd" And .Range("E" & RowCount) = "M" Then .Rows(RowCount).Copy _ Destination:=Sheets("Month").Rows(MonthRowCount) MonthRowCount = MonthRowCount + 1 End If If .Range("D" & RowCount) = "COD" And .Range("E" & RowCount) = "V" Then .Rows(RowCount).Copy _ Destination:=Sheets("Vic").Rows(VicRowCount) VicRowCount = VicRowCount + 1 End If If .Range("D" & RowCount) = "OPTD" And .Range("E" & RowCount) = "D" Then .Rows(RowCount).Copy _ Destination:=Sheets("Day").Rows(DayRowCount) DayRowCount = DayRowCount + 1 End If RowCount = RowCount + 1 Loop End With End Sub "Don Doan" wrote: Hi all, I have a "master" spreadsheet and 3 other spreadsheets "Month","Vic", "Day" all in the same workbook. how can i create a macro that go through the "master" sheet and look at column D and E (in the same row) to find certain conditions: if column D has "MVInd" and column E has the letter "M", then copy that row to the spreadsheet "Month" if column D has "COD" and column E has the letter "V", then copy that row to the spreadsheet "Vic" if column D has "OPTD" and column E has the letter "D", then copy that row the spreadsheet "Day" the macro should keep doing that until there is a blank row in the "master" sheet. Thank you very much. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
thank you very much, it works perfectly.
"Joel" wrote: Sub test() MonthRowCount = 1 VicRowCount = 1 DayRowCount = 1 RowCount = 1 With Sheets("Master") Do While .Range("D" & RowCount) < "" If .Range("D" & RowCount) = "MVInd" And .Range("E" & RowCount) = "M" Then .Rows(RowCount).Copy _ Destination:=Sheets("Month").Rows(MonthRowCount) MonthRowCount = MonthRowCount + 1 End If If .Range("D" & RowCount) = "COD" And .Range("E" & RowCount) = "V" Then .Rows(RowCount).Copy _ Destination:=Sheets("Vic").Rows(VicRowCount) VicRowCount = VicRowCount + 1 End If If .Range("D" & RowCount) = "OPTD" And .Range("E" & RowCount) = "D" Then .Rows(RowCount).Copy _ Destination:=Sheets("Day").Rows(DayRowCount) DayRowCount = DayRowCount + 1 End If RowCount = RowCount + 1 Loop End With End Sub "Don Doan" wrote: Hi all, I have a "master" spreadsheet and 3 other spreadsheets "Month","Vic", "Day" all in the same workbook. how can i create a macro that go through the "master" sheet and look at column D and E (in the same row) to find certain conditions: if column D has "MVInd" and column E has the letter "M", then copy that row to the spreadsheet "Month" if column D has "COD" and column E has the letter "V", then copy that row to the spreadsheet "Vic" if column D has "OPTD" and column E has the letter "D", then copy that row the spreadsheet "Day" the macro should keep doing that until there is a blank row in the "master" sheet. Thank you very much. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to count multiple conditions that are "TRUE" | Excel Discussion (Misc queries) | |||
copy rows based on conditions and insert them into another sheet... | Excel Programming | |||
if any of 3 conditions is true, then answer is true | Excel Worksheet Functions | |||
Copy multiple collumns with multiple conditions. | Excel Programming | |||
copy data from one sheet to another under conditions | Excel Discussion (Misc queries) |