Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Please help with code

Hi all again,

Tom Ogilvy gave me this code and it works great but I need it to insert into
sheet2 without replacing the data already there. How do I get it to do
this.



Sub CopyData()
Dim rng as Range, cell as Range, col as Long
Dim rw as Long, rng2 as Range
col = 3
rw = 2
With Worksheets("sheet1")
set rng = .range(.cells(2,col),.cells(rows.count,col).End(xl up))
End with
for each cell in rng
if lcase(cell.value) = "yes" then
cell.EntireRow.copy Destination:=worksheets("sheet2") _
.cells(rw,1)
rw = rw + 1
if rng2 is nothing then
set rng2 = cell
else
set rng2 = union(rng2,cell)
end if
end if
Next
if not rng2 is nothing then
rng2.EntireRow.Delete
End if
End Sub

Thanks in advance

Greg


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Please help with code

I worked it out thanks

Greg


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
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
Code to conditional format all black after date specified in code? wx4usa Excel Discussion (Misc queries) 3 December 26th 08 07:06 PM
Drop Down/List w/Code and Definition, only code entered when selec Spiritdancer Excel Worksheet Functions 2 November 2nd 07 03:57 AM
stubborn Excel crash when editing code with code, one solution Brian Murphy Excel Programming 0 February 20th 05 05:56 AM
option buttons run Click code when value is changed via VBA code neonangel Excel Programming 5 July 27th 04 08:32 AM


All times are GMT +1. The time now is 11:59 PM.

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

About Us

"It's about Microsoft Excel"