+ Reply to Thread
Results 1 to 6 of 6

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

  1. #1
    Marie J-son
    Guest

    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. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Marie,

    Could you post your code or an example of what your problem is and what you would like to happen. It isn't clear from this post what is happening with your code.

    Thanks,
    Leith Ross

  3. #3
    K Dales
    Guest

    RE: 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
    >
    >
    >


  4. #4
    Tom Ogilvy
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > 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. #5
    Marie J-son
    Guest

    Re: Help - loop through cells in a range that are not together (severa

    Thank you Dale,

    /Regards


    "K Dales" <[email protected]> skrev i meddelandet
    news:[email protected]...
    > 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
    >>
    >>
    >>




  6. #6
    Marie J-son
    Guest

    Re: 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" <[email protected]> skrev i meddelandet
    news:%[email protected]...
    > for each cell in Target
    >
    > Next
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    > "Marie J-son" <[email protected]> wrote in message
    > news:[email protected]...
    >> 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1