JoshTheTofu
New Member
- Joined
- Oct 15, 2020
- Messages
- 13
- Office Version
- 365
- Platform
- Windows
Hi guys
I have recently started a project on Excel and have hit a road block. I have learnt so much over the last few weeks although this is something that I have tried with but haven't found a solution. So I have come to you for some help.
I have a VBA macro which runs through a list of headers and prints each sheet out with the corresponding names. Here is the code:
I have set the list to a maximum of 100 rows and used an =IFERROR(x,"") to hide all the erros when it runs out of names to find. The problem here is it prints the "blank" pages too. Is there a piece of code to add to the VBA to improve it and only print upto the last visible row? Or alternatively is there a better way to display the data without having to"fill" the 100 rows?
Also I am really keen on understanding the answer to this as I have really enjoyed learning about excel recently and can see myself doing more in the future.
Kind regards
Josh
I have recently started a project on Excel and have hit a road block. I have learnt so much over the last few weeks although this is something that I have tried with but haven't found a solution. So I have come to you for some help.
I have a VBA macro which runs through a list of headers and prints each sheet out with the corresponding names. Here is the code:
VBA Code:
Sub Printout()
Dim xRg As Range
Dim xCell As Range
Dim xRgVList As Range
Set xRg = Worksheets("Print sheet").Range("A5")
Set xRgVList = Evaluate(xRg.Validation.Formula1)
For Each xCell In xRgVList
xRg = xCell.Value
If Not Application.WorksheetFunction.IsError(Range("B13")) = True Then
Worksheets("Print sheet").PrintOut
End If
Next
End Sub
I have set the list to a maximum of 100 rows and used an =IFERROR(x,"") to hide all the erros when it runs out of names to find. The problem here is it prints the "blank" pages too. Is there a piece of code to add to the VBA to improve it and only print upto the last visible row? Or alternatively is there a better way to display the data without having to"fill" the 100 rows?
Also I am really keen on understanding the answer to this as I have really enjoyed learning about excel recently and can see myself doing more in the future.
Kind regards
Josh
Last edited by a moderator: