Help - loop through cells in a range that are not together (several different cells as Target)

M

Marie J-son

Hi,

I'm stuck. I need to loop through each cell with my code and get range
error. I belive it is because the range consist of cells that are not
together.Right?

Actually, the event is when you copy one cell and select a number of others
and paste - dadaam, all cells have the same value as the copied cell. I use
Worksheet_change event and now I need to run some code with each cell in
Target.

How to do that?

/Kind regards
 
K

K Dales

Can't really tell what is going wrong without seeing your code. but here is a
way to loop through the target range cell by cell, even if the cells are
non-adjacent:

Dim K As Range

MsgBox Target.Address ' shows the address that Target itself is set to

For Each K In Target.Cells
MsgBox K.Address ' shows that now K is one of the individual cells in
Target
Next K
 
M

Marie J-son

Thank you Dale,

/Regards


K Dales said:
Can't really tell what is going wrong without seeing your code. but here
is a
way to loop through the target range cell by cell, even if the cells are
non-adjacent:

Dim K As Range

MsgBox Target.Address ' shows the address that Target itself is set to

For Each K In Target.Cells
MsgBox K.Address ' shows that now K is one of the individual cells in
Target
Next K
 
M

Marie J-son

Damn you, Tom. Why does it look so easy for you...-)

Working all right, of course

Thanks you
/Regards
 

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

Top