Printing A Chart

  • Thread starter Thread starter Jackie
  • Start date Start date
J

Jackie

I have a date in cell JI (dd/mmm/yy) I would like to print the corresponding
months chart, which is on a separate sheet. The tabs are named *** Sept**
and *****Oct*** etc, * = letters/numbers, person who set the charts up
didn't follow the same naming method for each chart. Is it possible to
search the tabs for the three letter month abbreviation and print that
chart.

Date = 28/Sep/04 print Sep Sheet
Date = 03/Oct/04 print Oct sheet

Thanks, Jackie
 
I have a date in cell JI (dd/mmm/yy) I would like to print the corresponding
months chart, which is on a separate sheet. The tabs are named *** Sept**
and *****Oct*** etc, * = letters/numbers, person who set the charts up
didn't follow the same naming method for each chart. Is it possible to
search the tabs for the three letter month abbreviation and print that
chart.

Date = 28/Sep/04 print Sep Sheet
Date = 03/Oct/04 print Oct sheet

Thanks, Jackie

Assuming the sheets to be printed are in the active workbook and that
the date is in the active sheet maybe this can be something to test.

Sub print_sheets_with_name_including_month_from_date_in_cell_J1()
months = "janfebmaraprmayjunjulaugsepoctnovdec"
mon = Mid(months, 3 * Month(Range("J1").Value) - 2, 3)
For i = 1 To Worksheets.Count
If InStr(LCase(Worksheets(i).Name), mon) > 0 Then
Worksheets(i).PrintOut
End If
Next i
End Sub

Hope this helps

Lars-Åke
 
Lars-Åke Aspelin, Thanks


Lars-Åke Aspelin said:
Assuming the sheets to be printed are in the active workbook and that
the date is in the active sheet maybe this can be something to test.

Sub print_sheets_with_name_including_month_from_date_in_cell_J1()
months = "janfebmaraprmayjunjulaugsepoctnovdec"
mon = Mid(months, 3 * Month(Range("J1").Value) - 2, 3)
For i = 1 To Worksheets.Count
If InStr(LCase(Worksheets(i).Name), mon) > 0 Then
Worksheets(i).PrintOut
End If
Next i
End Sub

Hope this helps

Lars-Åke
 
Lars-Åke

Code worked great but I have found there are several charts with the month
and they all print. Charts can there be something like RC*** "mon" **.
Hall**** "mon"*** etc *=wildcards.
can chart be found with specific letters *RC*** and "mon"** to be printed

Thanks, Jackie
 
Maybe...

Option Explicit
Sub print_sheets_with_name_including_month_from_date_in_cell_J1_v2()
Dim myStr As String
Dim wks As Worksheet

'get the month string from J1
myStr = Format(Worksheets("sheet1").Range("j1").Value, "mmm")

myStr = "*rc*" & myStr & "*"
For Each wks In ActiveWorkbook.Worksheets
If LCase(wks.Name) Like LCase(myStr) Then
wks.PrintOut preview:=True
Exit For 'only one to print???
End If
Next wks

End Sub

If you have more than one worksheet that can match your naming convention,
remove the "exit for" line.

And remove the preview:=true after you've tested it. (No sense killing trees!)
 
Back
Top