#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 747
Default Macro Code

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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Macro Code

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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 747
Default Macro Code

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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Macro Code

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 -



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
macro code muddan madhu Excel Discussion (Misc queries) 1 April 6th 08 03:44 PM
Macro code Shu of AZ Excel Discussion (Misc queries) 8 December 2nd 07 12:52 AM
Deleting code from a macro (by a macro) Brettjg Excel Discussion (Misc queries) 2 May 8th 07 10:14 PM
Help With Macro Code?? Neil Smith Excel Worksheet Functions 1 August 24th 06 07:40 PM
Macro VB code help Anthony Excel Discussion (Misc queries) 4 October 8th 05 07:25 PM


All times are GMT +1. The time now is 08:29 PM.

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"