Printing using vlookup

  • Thread starter Thread starter Pinda
  • Start date Start date
P

Pinda

Hi,

I have a spreadsheet that displays a different table of
data when triggered by a unique code, using vlookup.

So for example, if I enter a code in cell A1 (using a data
validation list with a named range) it displays a set of
figures in the table underneath.

e.g
Vlookup(A1,dataTable,2,false)... and so on..

What I want to do using VBA, is to go through the list of
codes and print each table out as it is displayed in the
spreadsheet.

I could record a macro where I select each code in A1 and
press print each time, but this is a bit long-winded.

Could someone please help with this code as my VBA is
quite limited. I am thinking some sort of loop could do
it. I would be very grateful.

Thank you.

Pinda
 
Pinda,

The loop would be something like this, with the sheet you want to print
active:

Sub PrintAll()
Dim myCell As Range

For Each myCell In Range("DataValidationSourceRange")
Range("A1").Value = myCell.Value
Application.CalculateFull
Activesheet.PrintOut
Next myCell

End Sub

HTH,
Bernie
MS Excel MVP
 
That works great, thanks very much!!

Pinda
-----Original Message-----
Pinda,

The loop would be something like this, with the sheet you want to print
active:

Sub PrintAll()
Dim myCell As Range

For Each myCell In Range("DataValidationSourceRange")
Range("A1").Value = myCell.Value
Application.CalculateFull
Activesheet.PrintOut
Next myCell

End Sub

HTH,
Bernie
MS Excel MVP




.
 
Back
Top