Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Suppose I have some data in Column A to Column D
Column A - names Column B - score Column C - result Column D - stats There are 100 names in a list If the column d , row 2 has the word "go" then it should copy entire row and paste in a new workbook. If row 3 has the word "no" then it should not copy , move to next row .. What code should i write to execute the above condition... Thanks in advance...... |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
From workbook Book1 to Book2:
Sub moveum() n = Cells(Rows.Count, "D").End(xlUp).Row Set rmv = Nothing For i = 1 To n If Cells(i, "D").Value = "go" Then If rmv Is Nothing Then Set rmv = Cells(i, "D").EntireRow Else Set rmv = Union(rmv, Cells(i, "D").EntireRow) End If End If Next rmv.Copy Workbooks("Book2").Sheets("Sheet1").Range("A1") End Sub -- Gary''s Student - gsnu2007h "muddan madhu" wrote: Suppose I have some data in Column A to Column D Column A - names Column B - score Column C - result Column D - stats There are 100 names in a list If the column d , row 2 has the word "go" then it should copy entire row and paste in a new workbook. If row 3 has the word "no" then it should not copy , move to next row .. What code should i write to execute the above condition... Thanks in advance...... |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
its giving
Run time error 9 : subscript out of range On Apr 13, 9:21*pm, Gary''s Student wrote: From workbook Book1 to Book2: Sub moveum() n = Cells(Rows.Count, "D").End(xlUp).Row Set rmv = Nothing For i = 1 To n * * If Cells(i, "D").Value = "go" Then * * * * If rmv Is Nothing Then * * * * * * Set rmv = Cells(i, "D").EntireRow * * * * Else * * * * * * Set rmv = Union(rmv, Cells(i, "D").EntireRow) * * * * End If * * End If Next rmv.Copy Workbooks("Book2").Sheets("Sheet1").Range("A1") End Sub -- Gary''s Student - gsnu2007h "muddan madhu" wrote: Suppose I have some data in Column A to Column D Column A - names Column B - score Column C - result Column D - stats There are 100 names in a list If the column d , row 2 has the word "go" then it should copy entire row *and paste in a new workbook. If row 3 has the word "no" then it should not copy , move to next row .. What code should i write to execute the above condition... Thanks in advance......- Hide quoted text - - Show quoted text - |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
You may need to replace:
rmv.Copy Workbooks("Book2").Sheets("Sheet1").Range("A1") with: rmv.Copy Workbooks("Book2.xls").Sheets("Sheet1").Range("A1" ) This code depends upon the names Book1, Book2, Sheet1, etc. -- Gary''s Student - gsnu2007g "muddan madhu" wrote: its giving Run time error 9 : subscript out of range On Apr 13, 9:21 pm, Gary''s Student wrote: From workbook Book1 to Book2: Sub moveum() n = Cells(Rows.Count, "D").End(xlUp).Row Set rmv = Nothing For i = 1 To n If Cells(i, "D").Value = "go" Then If rmv Is Nothing Then Set rmv = Cells(i, "D").EntireRow Else Set rmv = Union(rmv, Cells(i, "D").EntireRow) End If End If Next rmv.Copy Workbooks("Book2").Sheets("Sheet1").Range("A1") End Sub -- Gary''s Student - gsnu2007h "muddan madhu" wrote: Suppose I have some data in Column A to Column D Column A - names Column B - score Column C - result Column D - stats There are 100 names in a list If the column d , row 2 has the word "go" then it should copy entire row and paste in a new workbook. If row 3 has the word "no" then it should not copy , move to next row .. What code should i write to execute the above condition... Thanks in advance......- Hide quoted text - - Show quoted text - |
#5
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]() Why not just use datafilterautofilterfilter on gocopypasteunfilter Record a macro desired -- Don Guillett Microsoft MVP Excel SalesAid Software "muddan madhu" wrote in message ... Suppose I have some data in Column A to Column D Column A - names Column B - score Column C - result Column D - stats There are 100 names in a list If the column d , row 2 has the word "go" then it should copy entire row and paste in a new workbook. If row 3 has the word "no" then it should not copy , move to next row .. What code should i write to execute the above condition... Thanks in advance...... |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
macro code | Excel Discussion (Misc queries) | |||
Macro code | Excel Discussion (Misc queries) | |||
Deleting code from a macro (by a macro) | Excel Discussion (Misc queries) | |||
Help With Macro Code?? | Excel Worksheet Functions | |||
Macro VB code help | Excel Discussion (Misc queries) |