Clearing ghost images

WhoCanDo

Board Regular
Joined
Dec 18, 2007
Messages
193
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

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
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,223,885
Messages
6,175,181
Members
452,615
Latest member
bogeys2birdies

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