Excel VBA Code for Worksheet and Chart

Kits_

New Member
Joined
Dec 19, 2016
Messages
7
Dear Someone,

Please, can someone help me with this?

I am trying to change the footer base on a cell range in a worksheet, everything works fine, except that one workbook contains a chart. Type mismatched is the error, which I know, that because of the chart and that I didn't declare it like the worksheet. I am trying to fix it through, but can't seem to know the correct code. Please help me. Below is my code.

Private SubWorkbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Dim sht As Worksheet
For Each sht In Sheets
sht.PageSetup.CenterFooter ="&""Calibri,Regular""&6&K01+024Ref:&F" & Space(30) &"&""Calibri,Regular""&6&K01+024Date ofIssue: " & Worksheets(1).Range("N16").Text
Range("N16").NumberFormat= "dd mmm yyyy"
sht.PageSetup.RightFooter= "&""Calibri,Regular""&6&K01+024Page&P of &N"
Next
Sheet9.PageSetup.CenterFooter= ""
Sheet9.PageSetup.RightFooter= ""
End Sub


Thank you very much
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Hi All,

I fixed it already. I just have to change the Worksheet in "Dim sht As Worksheet" to "Dim sht As Variant".

Thanks all anyway :)
 
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,739
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top