View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default select from a range only some cells

Dim rng as Range, i as Long
for i = 4 to 17
if cells(2,i) = "mon" then
if rng is nothing then
set rng = cells(4,i)
else
set rng = union(rng,cells(4,i))
end if
end if
Next
if not rng is nothing then
rng.select
End if

this assumes the string "mon" is in the cell. If it is a date and you want
to test for monday

if weekday(cells(2,i),Value) = 2 then

--
Regards,
Tom Ogilvy

"hulub" wrote in message
...

i need to select from a range (D4:Q4) (defined as range in vba) only the
cells that verify one condition taken from other range (D2:Q2). In range
D2:Q2 I have week days (mon, thu, etc) witch are repeating and I need to
select only mondays. In the selected cells I have to put some values...
How to do this?
Thank you!


--
hulub
------------------------------------------------------------------------
hulub's Profile:

http://www.excelforum.com/member.php...o&userid=14494
View this thread: http://www.excelforum.com/showthread...hreadid=261996