ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help - loop through cells in a range that are not together (several different cells as Target) (https://www.excelbanter.com/excel-programming/326714-help-loop-through-cells-range-not-together-several-different-cells-target.html)

Marie J-son[_5_]

Help - loop through cells in a range that are not together (several different cells as Target)
 
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 Dales[_2_]

Help - loop through cells in a range that are not together (severa
 
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


"Marie J-son" wrote:

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




Tom Ogilvy

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

Next

--
Regards,
Tom Ogilvy

"Marie J-son" wrote in message
...
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





Marie J-son[_5_]

Help - loop through cells in a range that are not together (severa
 
Thank you Dale,

/Regards


"K Dales" skrev i meddelandet
...
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


"Marie J-son" wrote:

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






Marie J-son[_5_]

Help - loop through cells in a range that are not together (several different cells as Target)
 
Damn you, Tom. Why does it look so easy for you...-)

Working all right, of course

Thanks you
/Regards

"Tom Ogilvy" skrev i meddelandet
...
for each cell in Target

Next

--
Regards,
Tom Ogilvy

"Marie J-son" wrote in message
...
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








All times are GMT +1. The time now is 03:00 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com