![]() |
Macro to select various cells
OK, Here is what I am trying to accomplish: I have a large worksheet I am working with and I am working on a macro to select certain cells that meet a specific criteria and copy and paste those cells only into another worksheet. I have the select and paste part down but how to I enable it to assign a condition? For example, I would like the macro to select all the cells that contain 99 in the front of the number of one column and copy those cells into another worksheet. Can someone please point me in the right direction? Thanks in advance. -Dave -- DSC174 ------------------------------------------------------------------------ DSC174's Profile: http://www.excelforum.com/member.php...o&userid=27553 View this thread: http://www.excelforum.com/showthread...hreadid=470759 |
Macro to select various cells
for each cell in Range("B2:B50")
if left(cell.Value,2) = "99" then if rng is nothing then set rng = cell else set rng = union(rng,cell) end if end if Next if not rng is nothing then rng.copy Destination:=Worksheets("Sheet3").Range("A1") end if depending on the arrangement of the cells you select you may be able to do it with one copy command as shown, or you may have to loop through your "rng" and copy each area individually. -- Regards, Tom Ogilvy "DSC174" wrote in message ... OK, Here is what I am trying to accomplish: I have a large worksheet I am working with and I am working on a macro to select certain cells that meet a specific criteria and copy and paste those cells only into another worksheet. I have the select and paste part down but how to I enable it to assign a condition? For example, I would like the macro to select all the cells that contain 99 in the front of the number of one column and copy those cells into another worksheet. Can someone please point me in the right direction? Thanks in advance. -Dave -- DSC174 ------------------------------------------------------------------------ DSC174's Profile: http://www.excelforum.com/member.php...o&userid=27553 View this thread: http://www.excelforum.com/showthread...hreadid=470759 |
All times are GMT +1. The time now is 02:00 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com