Results 1 to 4 of 4

Problems using IF statement in DO WHILE loop

Threaded View

  1. #1
    Registered User
    Join Date
    10-07-2008
    Location
    Felixstowe
    Posts
    4

    Problems using IF statement in DO WHILE loop

    Good Evening, Im hoping you can assist me

    I have the following loop that should look through my rows of data for the Value "Y" in column T, for those rows that contain "Y" it should update column K with the variable xdate

    For some reason it doesn't seem to work, it changes the first entry it finds and then seems to crash, I have to use CTRL+BREAK to stop it.

    Please can you help and let me know what I'm doing wrong ?

    Private Sub changedate_Click()
    Dim xdate As long
    Dim iBegin As Integer
    Dim iEnd As Integer
    
              
    Application.ScreenUpdating = False
        On Error GoTo GetOut:
        iBegin = 5 ' This is the row that the list starts
        iEnd = Sheets("Bookings").Range("B4").End(xlDown).Row
        
    
        MyNote = "Are you sure you wish to change the date for all marked bookings ?"
    
        'Display MessageBox
        Answer = MsgBox(MyNote, vbQuestion + vbYesNo, "Confirm Date Change")
        
        If Answer = vbNo Then
            'Code for No button Press
            GoTo GetOut
        Else
        
                    xdate = InputBox("Please enter new date", "New Date Entry", "dd/mm/yy")
                   
        
       Do While iBegin <= iEnd
            With Sheets("Bookings")
                If Cells(iBegin, 20).Value = "Y" Then
                   Cells(iBegin, 11).Value = CDate(xdate)
                Else
                    iBegin = iBegin + 1
                End If
            End With
        Loop
    Many thanks, Darren
    Last edited by walneyhammer; 05-18-2009 at 12:03 PM. Reason: Problem Solved

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