write a macro to print to search a list and print certain workshee

  • Thread starter Thread starter Scott Smith
  • Start date Start date
S

Scott Smith

Hello,

I need help writing a macro. I have a table with information about 30
people, some are active, some are inactive. Each person has a worksheet
assigned to them, and I have hyperlinks setup so once you click a person's
number, excel goes to their sheet, and there are hyperlinks within each sheet
to go back to the table.

So, I want a macro that will search my table, and for each active person, go
to their worksheet and print it.

I will also mention that my hope is I can then copy that macro and apply it
to a control button - to make it easier for my intended users of this file -
rather than having them run a macro.

Any suggestions?
 
Basically, you would use a for/each loop. Let's assume you have col A with
name and col B with an "x" to indicate active.

for each person in range("a2:a22")
if person.offset(,1)="x" then
'do something such as
sheets(person).printout
end if
next person
 
Hello Don and thank you for the help.

I have a few more questions. I apologize I'm not very familiar with macros.

Let me give a few more details, I have a table with 30 people. Each person
has a number, when I click on their number I am taken to that person's
worksheet. To get back I click on their name - on their individual worksheet
and I'm taken back to the master table.

Also in a column (5 columns down from their number) is a column that has
either active or inactive.

How does that change / add to what you already indicated?

Again thank you

Scott
 
If you like, send your workbook to my address below along with a snippet of
this message copied to an inserted sheet.
 
I sent this based on #1, #2, etc in col A where 1,2, etc is the sheet name
and "Active" in col I

Sub PrintActives()
mc = "I" 'column I

On Error Resume Next
For i = 10 To Cells(Rows.Count, mc).End(xlUp).Row
If Cells(i, mc) = "Active" Then
Sheets(CStr(i - 10)).PrintPreview
End If
Next i
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top