SOLVED

help on VBA loop

Copper Contributor

So, I'm just floundering here.  I am new to all of this but i need help.

 

Right now, I just want this to loop through a table and print the sheet for each person in the table.  We want to print out a whole month in advance, so it needs to know how many times to print the sheet for each name. (4 or 5) There is a lot I'm not understanding but this is what I have so far.  any direction would be appreciated

 

Sub PrintEntireJDT()
'
' PrintSheet for each individual in JDT Macro

' Dim Variables
Dim MonthYear As Date 'This is the value of MonthYear from cell R3 of Sheet Weekly Notes Master
Dim WeekOfStart As Date 'This is the value of WeekOf from cell L3 of Sheet Weekly Notes Master
Dim WeekOf As Date
Dim IndName As String 'This will be FirstName and LastName combined from Table IndData on sheet Names
Dim NumberOfWeeks As Byte
'This is how many weeks are in the month. Default is 5 This sets the number for
'how many times we loop for each IndName.(I'm thinking i set the loop to fixed number, but
'i could also just check the values in an if test. Not sure which is the best way?)
Dim Counter As Byte

'this is where I get extra confused and start to beat my head against the wall because I am stupid and dont understand why I cant get the syntax or the concept straight. I want to look up the data from Table IndData on Sheet Names. I am not sure what Variables i need for this. i think its something like this:

Dim IndData As Range ' i just dont get this part. range? list object? should it be called something other than the table name? Why can't I just use the table name? why do I need to declare it I guess is my question.



For Each Row In IndData

'Get the first and last name from IndData and puts value in IndName (L1) of Weekly Notes Master


'Sets Counter to 1
Counter = 1

Do While Counter <= NumberOfWeeks

'Prints Sheet and increases Counter and WeekOf
ActiveWindow.SelectedSheets.PrintOut Copies:=1
WeekOf = WeekOf + 7
Counter = Counter + 1
Loop

'set WeekOf back to beginning of month
WeekOf = WeekOfStart

Next Row
End Sub

2 Replies
best response confirmed by Stretch93514 (Copper Contributor)
Solution

@Stretch93514 Perhaps this gets you started?

Thanks for the jumpstart. It’s working perfect.
1 best response

Accepted Solutions
best response confirmed by Stretch93514 (Copper Contributor)
Solution

@Stretch93514 Perhaps this gets you started?

View solution in original post