Loop with variable in formula?

  • Thread starter Thread starter Dutchie
  • Start date Start date
D

Dutchie

Hi,

I'm a beginner with loops, and would really appreciate some help.

I have one worksheet which is an invoice. Another worksheet
[Address.xls]Labels! contains the invoice numbers in col A that need to
be entered into the invoice cell C3 and then printed, one at a time.

So I need a loop that will enter the invoice no from A2
[ADDRESS.XLS]Labels! into the invoice worksheet (always C3)....then A3
into C3...then A4 into C3...etc, til there is a blank cell in col A of
the invoice no's worksheet.

Here's the idea:

'Loop starting from here:

Range("C3").Select 'invoice file

ActiveCell.FormulaR1C1 = "=[ADDRESS.XLS]Labels!R2C1"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

'then go on to R3C1 etc

Can anyone help please?
Thanks!
Dutchie
 
Sub PrintInvoice()
Dim c As Range

For Each c In Range("A1:A" & Rows.Count)
If c.Value = "" Then
Exit For
End If
Range("c3").Value = c.Value
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Next c
End Su
 
Back
Top