Clearing ghost images

WhoCanDo

Board Regular
Joined
Dec 18, 2007
Messages
191
Hi,

I have written a macro to print worksheet to PDF

However, when the macro is finished, the worksheet displays a ghost line of the previous page when I click on cells around the sheet.

This ghost line is in the same place no matter where I click, however, if I scroll down and click, another ghost line appears. Likewise, when scrolling down.

I can stop this from happening if I turn off Private Sub Worksheet_SelectionChange(ByVal Target As Range) but it begins again when I turn it on again.

Here is the SelectionChange code ..

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'
Select Case (Range("E2").Value)
Case 10
Range("A1").Value = "Type3"
Range("A2").Value = "txtField1"
Case 32
Range("A1").Value = "Type2"
Range("A2").Value = "txtField1,txtField2"
Case Else
Range("E2").Value = 16
Range("A1").Value = "Type1"
Range("A2").Value = "txtField1"
End Select
End Sub

Here is the screen ghost, 1st, 2nd & 3rd scroll down clicking on different cells each time ..

1714982290476.png


This ghost images are not really there. If I pick a cell behind them, there is only an empty cell. If I print this page, the ghost doesn't print.

Interestingly, when I was Snipping these pictures, Excel was refreshing the screen each time without the ghost.

Any ideas ?
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
I've resolved the issue but not quite sure that I truly found the cause.

For those who find this in the future, here's what I did to stop it - for now :sneaky:.

I have a sheet that is hidden. When I print the set, that sheet is made visible and printed.

However, when it's time to print, I used "Sheets("???").Visible = True" just before "Sheets("???").Select".

When I moved the "Sheets("???").Visible = True" code up to the beginning of the macro, ie. separated it from "Sheets("???").Select", the problem went away.
 
Upvote 0

Forum statistics

Threads
1,216,101
Messages
6,128,842
Members
449,471
Latest member
lachbee

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