COMPILE ERROR END IF WITHOUT BLOCK IF
Sub EnterDates()
Columns().Clear
Dim EilDownloadSheet As Worksheet
Set EilDownloadSheet = Workbook.Worksheets("Name of worksheet")
Dim startDate As String, stopDate As String, startCel As Integer, stopcel As Integer, dateRange As Range
On Error Resume Next
Do
startDate = InputBox("Please enter start Date: format (dd/mm/yy)", "Start Date")
If startDate = "" Then End
Loop Until startDate = Format(startDate, "dd/mm/yy") Or startDate = Format(startDate, "m/d/yy")
Dim blnCancel As Boolean
Dim blnValid As Boolean
blnCancel = False
blnValid = False
Do
startDate = InputBox("Please enter start Date: format (dd/mm/yy)", "Start Date")
If startDate = vbNullString Then
blnCancel = True
Else
If CDate(startDate) = False Then
blnValid = False
Else
blnValid = True
End If
Do
Loop Until blnValid = True Or blnCancel = True
End If
End If
End If
End Sub

VBA WORKSHEET
hazz
Hey
I tried that then I get another error Do without Loop on the End Sub
Wodahs
Etienne Team System MVP
good day!
try deleting some end if's at the end of your code..
..........
Do
startDate = InputBox("Please enter start Date: format (dd/mm/yy)", "Start Date")
If startDate = vbNullString Then
blnCancel = True
Else
If CDate(startDate) = False Then
blnValid = False
Else
blnValid = True
End If
End If
Loop Until blnValid = True Or blnCancel = True
Tera_Dragon
i tried this block of code in here.. it looks fine.. your using vb2005 right
' ===================
Sub EnterDates()
Columns().Clear()
Dim EilDownloadSheet As Worksheet
EilDownloadSheet = Workbook.Worksheets("Name of worksheet")
Dim startDate As String, stopDate As String, startCel As Integer, stopcel As Integer, dateRange As Range
On Error Resume Next
Do
startDate = InputBox("Please enter start Date: format (dd/mm/yy)", "Start Date")
If startDate = "" Then End
Loop Until startDate = Format(startDate, "dd/mm/yy") Or startDate = Format(startDate, "m/d/yy")
Dim blnCancel As Boolean
Dim blnValid As Boolean
blnCancel = False
blnValid = False
Do
startDate = InputBox("Please enter start Date: format (dd/mm/yy)", "Start Date")
If startDate = vbNullString Then
blnCancel = True
Else
If IsDate(startDate) = False Then
blnValid = False
Else
blnValid = True
End If
End If
Loop Until blnValid = True Or blnCancel = True
' ===================
ondrejsv
and maybe you mean Isdate.. not Cdate to check the validity of the date.
...........................
Do
startDate = InputBox("Please enter start Date: format (dd/mm/yy)", "Start Date")
If startDate = vbNullString Then
blnCancel = True
Else
If IsDate(startDate) = False Then
blnValid = False
Else
blnValid = True
End If
End If
Loop Until blnValid = True Or blnCancel = True
lucius153
fr0zed
i try ur code here.. it works fine..
but try Microsoft ISV Community Center Forums they discuss VBA there more..
Chris Rossall
Sub EnterDates()
Columns().Clear
Dim EilDownloadSheet As Worksheet
Set EilDownloadSheet = Workbook.Worksheets("Name of worksheet")
Dim startDate As String, stopDate As String, startCel As Integer, stopcel As Integer, dateRange As Range
On Error Resume Next
Do
startDate = InputBox("Please enter start Date: format (dd/mm/yy)", "Start Date")
If startDate = "" Then End
Loop Until startDate = Format(startDate, "dd/mm/yy") Or startDate = Format(startDate, "m/d/yy")
Dim blnCancel As Boolean
Dim blnValid As Boolean
blnCancel = False
blnValid = False
Do 'missing loop
startDate = InputBox("Please enter start Date: format (dd/mm/yy)", "Start Date")
If startDate = vbNullString Then
blnCancel = True
Else
If CDate(startDate) = False Then 'should be IsDate()
blnValid = False
Else
blnValid = True
End If
Do 'or is this one wrong
Loop Until blnValid = True Or blnCancel = True
End If
End If 'missing if statement
End If 'missing if statement
End Sub
hopefully that will fix your compile errors.