select from a range only some cells

  • Thread starter Thread starter hulub
  • Start date Start date
H

hulub

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top