I found the following module code that has a input box for entering two digits for a particular week to print. Is there a way to convert this to entering month ie: January, February, etc.
Sub Print_Week_X()
Dim rngPrint As Range, wkNum As String
Dim rngFound As Range
'clear any previous settings for the print area
ActiveSheet.PageSetup.PrintArea = ""
Application.ScreenUpdating = False
tryagain:
'get the week number to print
On Error Resume Next
Application.DisplayAlerts = False
wkNum = ""
wkNum = Application.InputBox("Enter the week number as a two-digit number from 01 thru 12")
On Error GoTo 0
Application.DisplayAlerts = True
' If wkNum = "" Then GoTo endit:
If Len(wkNum) < 2 Then
MsgBox ("You must enter two digits for all week numbers")
GoTo tryagain:
End If
Set rngFound = Columns(2).Find(what:=wkNum, After:=Cells(1, 2), LookIn:=xlValues _
, lookat:=xlPart, searchorder:=xlByRows, searchdirection:=xlNext, MatchCase:=False)
If rngFound Is Nothing Then
MsgBox "The week number was not found"
GoTo endit:
End If
'MsgBox rngFound.Address
With ActiveSheet
.PageSetup.PrintArea = .Range("B" & rngFound.Row - 1, Range("Y" & rngFound.Row + 29)).Address
.Print
.PageSetup.PrintArea = ""
.PageSetup.PrintArea = .Range(.Cells(rngFound.Row - 1, 26), .Cells(rngFound.Row + 29, 43)).Address
.Print
End With
endit:
Application.ScreenUpdating = True
End Sub
I also found this code to search by text that will locate where text was found, but need to combine codes to search for text, ie month and be able to print that sheet.
Public Sub FindText()
Dim ws As Worksheet
Dim Found As Range
Dim myText As String
Dim FirstAddress As String
Dim AddressStr As String
myText = InputBox("Enter text to find")
If myText = "" Then Exit Sub
For Each ws In ThisWorkbook.Worksheets
With ws
Set Found = .UsedRange.Find(what:=myText, LookIn:=xlValues, MatchCase:=False)
If Not Found Is Nothing Then
FirstAddress = Found.Address
Do
AddressStr = AddressStr & .Name & " " & Found.Address & vbCrLf
Set Found = .UsedRange.FindNext(Found)
Loop While Not Found Is Nothing And Found.Address <> FirstAddress
End If
End With
Next ws
If Len(AddressStr) Then
MsgBox AddressStr, vbOKOnly, myText & " found in these cells"
Else:
MsgBox "Unable to find " & myText & " in this workbook.", vbExclamation
End If
End Sub
Bookmarks