vzachin
09-18-2006, 03:53 AM
Hi,
I have a macro that basically queries a mainframe for data and copies & pastes the information back to Excel.
Knowing the row limitation in Excel,
(1) how can I have the macro stop and error out with a message when it approaches the last row
or
(2) if it reaches the last row, can I continue pasting in other columns instead? this is what i would prefer to do
Sub RowLimit()
Dim Rw As Long
Rw = 4
'This sheet contains the data which queries the mainframe
Sheets("Data").Select
For i = 5 To 65536
If Range("A" & i).FormulaR1C1 = "" Then
MsgBox "Completed"
Exit Sub
End If
'Macro then retrieves data from the mainframe
'And adds the information to Excel
'This adds the data to Excel, where i have the question about the row limits
Rw = Rw + 1
With Worksheets("OUTPUT")
.Cells(Rw, "C").Value = City
.Cells(Rw, "D").Value = County
End With
Next
End Sub
thanks
zach
I have a macro that basically queries a mainframe for data and copies & pastes the information back to Excel.
Knowing the row limitation in Excel,
(1) how can I have the macro stop and error out with a message when it approaches the last row
or
(2) if it reaches the last row, can I continue pasting in other columns instead? this is what i would prefer to do
Sub RowLimit()
Dim Rw As Long
Rw = 4
'This sheet contains the data which queries the mainframe
Sheets("Data").Select
For i = 5 To 65536
If Range("A" & i).FormulaR1C1 = "" Then
MsgBox "Completed"
Exit Sub
End If
'Macro then retrieves data from the mainframe
'And adds the information to Excel
'This adds the data to Excel, where i have the question about the row limits
Rw = Rw + 1
With Worksheets("OUTPUT")
.Cells(Rw, "C").Value = City
.Cells(Rw, "D").Value = County
End With
Next
End Sub
thanks
zach