Hi everybody,
I need some help with this macro. I know very very little about code, but found this macro online to help me with a project at work. It is basically a mail merge, without using Word. It uses data from one worksheet to fill in certain cells in another worksheet. This macro is supposed to print each form once with the data, then the next form with the next row of data, etc. I believe it was created with Excel 2003, and I'm running 2000, which i'm sure is the main source of trouble. The debugger highlights the "StartRow = Range("StartRow") line as the problem. The error I get is "Run-time error 1004. method 'Range' of object '_Global' failed" Again, I know very little about VB, so any help at all would be appreciated. Thanks
Sub PrintForms()
Dim StartRow As Integer
Dim EndRow As Integer
Dim Msg As String
Dim i As Integer
Sheets("Form").Activate
StartRow = Range("StartRow")
EndRow = Range("EndRow")
If StartRow > EndRow Then
Msg = "ERROR" & vbCrLf & "The starting row must be less than the ending row!"
MsgBox Msg, vbCritical, APPNAME
End If
For i = StartRow To EndRow
Range("RowIndex") = i
If Range("Preview") Then
ActiveSheet.PrintPreview
Else
ActiveSheet.PrintOut
End If
Next i
End Sub
I need some help with this macro. I know very very little about code, but found this macro online to help me with a project at work. It is basically a mail merge, without using Word. It uses data from one worksheet to fill in certain cells in another worksheet. This macro is supposed to print each form once with the data, then the next form with the next row of data, etc. I believe it was created with Excel 2003, and I'm running 2000, which i'm sure is the main source of trouble. The debugger highlights the "StartRow = Range("StartRow") line as the problem. The error I get is "Run-time error 1004. method 'Range' of object '_Global' failed" Again, I know very little about VB, so any help at all would be appreciated. Thanks
Sub PrintForms()
Dim StartRow As Integer
Dim EndRow As Integer
Dim Msg As String
Dim i As Integer
Sheets("Form").Activate
StartRow = Range("StartRow")
EndRow = Range("EndRow")
If StartRow > EndRow Then
Msg = "ERROR" & vbCrLf & "The starting row must be less than the ending row!"
MsgBox Msg, vbCritical, APPNAME
End If
For i = StartRow To EndRow
Range("RowIndex") = i
If Range("Preview") Then
ActiveSheet.PrintPreview
Else
ActiveSheet.PrintOut
End If
Next i
End Sub