+ Reply to Thread
Results 1 to 3 of 3

If Statement in VB

Hybrid View

INeedHelp09 If Statement in VB 03-03-2009, 07:07 AM
alski Re: If Statement in VB 03-03-2009, 07:15 AM
INeedHelp09 Re: If Statement in VB 03-03-2009, 07:26 AM
  1. #1
    Registered User
    Join Date
    03-03-2009
    Location
    Liverpool
    MS-Off Ver
    Excel 2003
    Posts
    4

    If Statement in VB

    I am looking to get my vb code to do a simple thing, i need it to look at a date on my excel doc and to flag a messagebox that it cannot run due to date passed only if the date is exceeded otherwise i would like the code to complete?? I am very new to all this also

    If Now >= cell value"e8" Then MsgBox "Cannot Submit Form" Else
    
    
    'create the text file
    Open strFile For Output As intFile
    
    'Start going through list
    
    intRowCount = 17
    
    With Sheets("DevSlots")
        Do Until .Cells(intRowCount, 1) = ""
        Time = .Cells(intRowCount, 2)
        SchedDate = .Cells(intRowCount, 3)
        EndTime = .Cells(intRowCount, 4)
        
                For colIndex = 6 To 45
                          If .Cells(intRowCount, colIndex).Value = "" Then
                          Else: Print #intFile, .Cells(intRowCount, colIndex) & "|" & "DevSlot" & "|" & Format(SchedDate, "YYYYMMDD") & "|" & Format(Time, "hh:mm") & "|" & Format(EndTime, "hh:mm")
                          End If
                Next colIndex
                        
            intRowCount = intRowCount + 1
        Loop
    End With
    
    Close intFile
    
    End Sub
    Last edited by mudraker; 03-03-2009 at 07:26 AM.

  2. #2
    Registered User
    Join Date
    02-19-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003 and Excel 2007
    Posts
    37

    Re: If Statement in VB

    Try this - now returns a Date and Time whereas date returns just the date

    if date >= .range("E8") then
    
    msgbox "Cannot Submit Form"
    
    end if
    Last edited by mudraker; 03-03-2009 at 07:27 AM.

  3. #3
    Registered User
    Join Date
    03-03-2009
    Location
    Liverpool
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: If Statement in VB

    I need it to stop at that point if the date is past todays date or for it to continue if it is not?? Hope this makes sense

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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