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


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



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




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





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






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
Several target cells in the solver omathilde Excel Discussion (Misc queries) 4 October 23rd 09 05:06 PM
Maintaining a cells value once a target is achieved cliff18 Excel Worksheet Functions 9 January 10th 09 04:11 AM
How do I loop a range of cells until I get a numeric value? ManKind New Users to Excel 1 June 4th 06 06:48 AM
Target Cells Bohdon Excel Worksheet Functions 1 February 23rd 06 09:18 PM
Defining Range of For Each Loop for Cells and Worksheets ExcelMonkey[_190_] Excel Programming 2 February 22nd 05 01:04 PM


All times are GMT +1. The time now is 12:57 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"