B
Brett Smith
I wrote a program that goes through a bunch of records and then spits out an
rdf file. My problem is, when it asks for the first upper most record and
the person hits cancel on the dialog box, I get a run-time error '424'. I am
not sure how to handle this, and I would like to have a dialog box pulled up
asking are you sure? Below is the code below....
After the code below, I have a series of select statements that follow in my
program...
Sub GetRows()
Dim FirstCell As Range, LastCell As Range
Dim Firstrow As Long, Lastrow As Long
Dim Wordstring As String
Dim filePath As String
Dim I As Integer
Dim FName As Variant
Wordstring = "$RDFILE 1" & vbCrLf & _
"$DATM " & Date & " " & Time & vbCrLf & _
"$RIREG 1" & vbCrLf & _
"$DTYPE BATCH: CHEMIST" & vbCrLf & _
"$DATUM REIDHAAJ" & vbCrLf & _
"$DTYPE BATCH: STRUCT_CMNT" & vbCrLf & _
"$DATUM [NUCLEIC ACID]" & vbCrLf & _
"$DTYPE STRUCTURE" & vbCrLf & _
"$DATUM $MFMT"
filePath = ActiveWorkbook.Path & "\Seqfile.rdf"
Open filePath For Output As #1
Print #1, Wordstring
Do
Set FirstCell = Application.InputBox("Enter top left cell - ONE cell
only ", Type:=8)
'''After this line, I would like to have an error handler for the Cancel
button, but it fails miserably no matter what I do. I'm not sure how to
handle this one.
Loop Until FirstCell.Count = 1
Firstrow = FirstCell.Row
Do
Set LastCell = Application.InputBox("Enter bottom right cell - ONE
cellonly ", Type:=8)
'''I would like to have an error handler for this line too
Loop Until LastCell.Count = 1
Lastrow = LastCell.Row
Firstrow = Int(Firstrow)
Lastrow = Int(Lastrow)
MsgBox Firstrow & " " & Lastrow
Range(Firstrow & ":" & Lastrow).Select
For I = Firstrow To Lastrow
If IsEmpty(Cells(I, "C").Value) Then
Dim G As Variant
Dim H As Variant
Select Case IsEmpty(Cells(I, "G").Value) Or Cells(I, "G").Value
= " "
rdf file. My problem is, when it asks for the first upper most record and
the person hits cancel on the dialog box, I get a run-time error '424'. I am
not sure how to handle this, and I would like to have a dialog box pulled up
asking are you sure? Below is the code below....
After the code below, I have a series of select statements that follow in my
program...
Sub GetRows()
Dim FirstCell As Range, LastCell As Range
Dim Firstrow As Long, Lastrow As Long
Dim Wordstring As String
Dim filePath As String
Dim I As Integer
Dim FName As Variant
Wordstring = "$RDFILE 1" & vbCrLf & _
"$DATM " & Date & " " & Time & vbCrLf & _
"$RIREG 1" & vbCrLf & _
"$DTYPE BATCH: CHEMIST" & vbCrLf & _
"$DATUM REIDHAAJ" & vbCrLf & _
"$DTYPE BATCH: STRUCT_CMNT" & vbCrLf & _
"$DATUM [NUCLEIC ACID]" & vbCrLf & _
"$DTYPE STRUCTURE" & vbCrLf & _
"$DATUM $MFMT"
filePath = ActiveWorkbook.Path & "\Seqfile.rdf"
Open filePath For Output As #1
Print #1, Wordstring
Do
Set FirstCell = Application.InputBox("Enter top left cell - ONE cell
only ", Type:=8)
'''After this line, I would like to have an error handler for the Cancel
button, but it fails miserably no matter what I do. I'm not sure how to
handle this one.
Loop Until FirstCell.Count = 1
Firstrow = FirstCell.Row
Do
Set LastCell = Application.InputBox("Enter bottom right cell - ONE
cellonly ", Type:=8)
'''I would like to have an error handler for this line too
Loop Until LastCell.Count = 1
Lastrow = LastCell.Row
Firstrow = Int(Firstrow)
Lastrow = Int(Lastrow)
MsgBox Firstrow & " " & Lastrow
Range(Firstrow & ":" & Lastrow).Select
For I = Firstrow To Lastrow
If IsEmpty(Cells(I, "C").Value) Then
Dim G As Variant
Dim H As Variant
Select Case IsEmpty(Cells(I, "G").Value) Or Cells(I, "G").Value
= " "