+ Reply to Thread
Results 1 to 8 of 8

looping with dates

Hybrid View

johncon looping with dates 01-07-2009, 06:30 AM
royUK Is this what you need ... 01-07-2009, 06:40 AM
johncon Thanks for the reply This... 01-07-2009, 06:52 AM
royUK Try this amendment Dim... 01-07-2009, 06:54 AM
johncon 99% there The only issue... 01-07-2009, 07:11 AM
royUK Try bthis Dim rng As... 01-07-2009, 07:32 AM
johncon RoyUk Many thanks Works... 01-07-2009, 07:36 AM
royUK Glkad it helped If you are... 01-07-2009, 07:41 AM
  1. #1
    Registered User
    Join Date
    03-04-2008
    Posts
    32

    Cool looping with dates

    I have a worksheet with 2 columns, row 1 is the header and row 2 will be information and date.
    What I then need to do is check that if thre is anything in the next row (A3) if so then (B3) will be the same date as (B2), I need to do this untill Column A has a blank row

    Hope this is comprehensible?

    Using excel 2000

    Many thanks
    John
    Last edited by johncon; 01-07-2009 at 09:44 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Is this what you need

    Dim rng As Range
    Dim cl As Range
    
    Set rng = Range(Cells(2, 1), Cells(Rows.Count, 1).End(xlUp))
    
    For Each cl In rng
    If Not IsEmpty(cl) Then cl.Offset(0, 1).Value = cl.Offset(-1, 1).Value
    Next cl
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    03-04-2008
    Posts
    32
    Thanks for the reply

    This nearly works.

    But it copies the header from A1 instead of the dates from A2

    Cheers
    john

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Try this amendment
    Dim rng As Range
    Dim cl As Range
    
    Set rng = Range(Cells(2, 1), Cells(Rows.Count, 1).End(xlUp))
    
    For Each cl In rng
    If Not IsEmpty(cl) And IsEmpty(cl.Offset(0, 1)) Then cl.Offset(0, 1).Value = _
        cl.Offset(-1, 1).Value
    Next cl

  5. #5
    Registered User
    Join Date
    03-04-2008
    Posts
    32
    99% there

    The only issue now is that if B2 is empty it takes the value from B1.

    I would like it all to be blank if B2 is empty


    Many thanks
    John

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Try bthis
    Dim rng As Range
    Dim cl As Range
    
    If IsEmpty(Cells(2, 2)) Then Exit Sub
    Set rng = Range(Cells(2, 1), Cells(Rows.Count, 1).End(xlUp))
    
    For Each cl In rng
    If Not IsEmpty(cl) And IsEmpty(cl.Offset(0, 1)) Then cl.Offset(0, 1).Value = _
        cl.Offset(-1, 1).Value
    Next cl

  7. #7
    Registered User
    Join Date
    03-04-2008
    Posts
    32
    RoyUk

    Many thanks

    Works a treat

    Cheers
    John

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Glkad it helped

    If you are satisfied with the solution(s) provided, please mark your thread as Solved and rate the answer(s)

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ 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