ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Printing A Chart (https://www.excelbanter.com/excel-programming/312282-printing-chart.html)

Jackie[_4_]

Printing A Chart
 
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




Lars-Åke Aspelin

Printing A Chart
 
On Sun, 03 Oct 2004 12:12:26 GMT, "Jackie" wrote:

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_i n_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

Jackie[_4_]

Printing A Chart
 
Lars-Åke Aspelin, Thanks


"Lars-Åke Aspelin" wrote in message
...
On Sun, 03 Oct 2004 12:12:26 GMT, "Jackie" wrote:

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_i n_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




Jackie[_4_]

Printing A Chart
 
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

"Jackie" wrote in message
o.uk...
Lars-Åke Aspelin, Thanks


"Lars-Åke Aspelin" wrote in message
...
On Sun, 03 Oct 2004 12:12:26 GMT, "Jackie" wrote:

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_i n_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






Dave Peterson[_3_]

Printing A Chart
 
Maybe...

Option Explicit
Sub print_sheets_with_name_including_month_from_date_i n_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!)

Jackie wrote:

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

"Jackie" wrote in message
o.uk...
Lars-Åke Aspelin, Thanks


"Lars-Åke Aspelin" wrote in message
...
On Sun, 03 Oct 2004 12:12:26 GMT, "Jackie" wrote:

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_i n_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




--

Dave Peterson



All times are GMT +1. The time now is 09:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com