#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel macro

I would like to extract rows from one sheet and add them to another
sheet if there is the character 's' is in the cell under column k. How
do I do this? TIA.

--
Posted via a free Usenet account from http://www.teranews.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Excel macro

Sub CopyData()
Dim cell as range, rng1 as Range, rng as range
Dim sh as worksheet
With worksheets("Sheet1")
set rng = .Range(.cells(2,"k"),.cells(2,"k").End(xlup))
End with
set sh = worksheets("Sheet2")
for each cell in rng
if lcase(cell.value) = "s" then
if rng1 is nothing then
set rng1 = cell
else
set rng1 = union(rng1,cell)
end if
end if
Next
if not rng1 is nothing then
rng1.EntireRow.Copy Destination:= _
sh.cells(rows.count,1).end(xlup)(2)
End if
End sub

--
Regards,
Tom Ogilvy


"Pierre Fichaud" wrote in message
.. .
I would like to extract rows from one sheet and add them to another sheet
if there is the character 's' is in the cell under column k. How do I do
this? TIA.

--
Posted via a free Usenet account from http://www.teranews.com



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 Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
Call macro stored in Excel workbook from Outlook's macro Gvaram Excel Programming 0 October 4th 06 05:47 PM
Need syntax for RUNning a Word macro with an argument, called from an Excel macro Steve[_84_] Excel Programming 3 July 6th 06 07:42 PM
translate lotus 1-2-3 macro into excel macro using excel 2000 krutledge0209 Excel Programming 1 November 2nd 04 05:50 PM
Excel Macro Issue Trying to autorun Macro Upon Opening Worksheet wyndman Excel Programming 2 May 25th 04 06:59 PM


All times are GMT +1. The time now is 04:11 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"