Run-time error 1004

tgabay

New Member
Joined
Nov 23, 2005
Messages
1
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
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
It looks like there should be a defined name called "StartRow"... make sure it exists
 
Upvote 0

Forum statistics

Threads
1,224,249
Messages
6,177,423
Members
452,774
Latest member
Macca1962

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top