VBA to print multiple names from a column.

RedOctoberKnight

Board Regular
Joined
Nov 16, 2015
Messages
150
Office Version
  1. 2016
Platform
  1. Windows
Good Morning,

I have a list of names in two columns (K3:K:20 and N3:N20). I want each name to appear in Cell B1 and print the sheet. If possible, I'd like it to skip blank cells in the names list. I'd like it to run through both columns of names so I can just run the VBA and it will go through each name and print the sheet. Sorry, I'm sure I'm not explaining this very well.

so in theory,

B1 equals K3 and prints sheet, Then
B1 equals K4 and prints sheet, then
B1 equals K5 and prints sheet and so on down to K:20 and then does the same thing for the names in column N3:N20. I would like it to skip blank cells if possible.

Any help would be much appreciated.
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Give this a try:
VBA Code:
Sub t()
Dim c As Range, rng As Range
Set rng = Union(Range("K3:K20"), Range("N3:N20"))
    For Each c In rng
        If c <> "" Then
            Range("B1") = c.Value
            ActiveSheet.PrintOut
        End If
    Next
End Sub
 
Upvote 0
Give this a try:
VBA Code:
Sub t()
Dim c As Range, rng As Range
Set rng = Union(Range("K3:K20"), Range("N3:N20"))
    For Each c In rng
        If c <> "" Then
            Range("B1") = c.Value
            ActiveSheet.PrintOut
        End If
    Next
End Sub


Anyway I can get it to print a copy of "sheet2" as well every time it runs through a name?
 
Upvote 0
VBA Code:
Sheet2.PrintOut
add after ActiveSheet.PrintOut
 
Upvote 0

Forum statistics

Threads
1,214,826
Messages
6,121,797
Members
449,048
Latest member
greyangel23

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