Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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



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 to select cells without a certain value and select a menu it Guy[_2_] Excel Worksheet Functions 9 January 2nd 09 05:21 PM
need a macro select all cells in a worksheet? MarkN Excel Discussion (Misc queries) 0 June 23rd 06 12:47 AM
Want macro to select & copy cells from a different worksheet RocketRod Excel Discussion (Misc queries) 5 February 28th 06 12:53 PM
How do I pause a macro to select specific cells lee Excel Worksheet Functions 1 April 2nd 05 02:11 PM
how to select cells dynamically in excel macro? Excel user Excel Programming 1 November 1st 04 05:28 PM


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