View Full Version : [SOLVED:] Unwanted selection change
mdmackillop
07-28-2017, 06:44 AM
In another question, my solution is changing selection if run from the "source" page, ie. the target range on Sheet Main is showing as selected on sheet Raw. Any reason for this? Other than this, the result is OK.
Paul_Hossler
07-28-2017, 07:10 AM
ref: http://www.vbaexpress.com/forum/showthread.php?29500-screen-redraw-problem-(not-ScreenUpdating)
I think it's just a left over video ghost from 'Main' on 'Raw'
The
MsgBox Selection.Address(1, 1, 1, 1)
Line still shows A1 as the Selection
Goes away after forcing a re-paint by coming back to Raw
Option Explicit
Sub Demo1()
Dim rwsR As Long, rwsM As Long, x As Long
Dim RW As Long
rwsR = Sheets("Raw").Columns(1).SpecialCells(2, 1).Count
rwsM = Sheets("Main").Columns(1).SpecialCells(2, 1).Count
RW = Sheets("Main").Columns(1).SpecialCells(2, 1).Row
Worksheets("Raw").Range("a1").Select ' force Selection to known
With Sheets("Main")
x = rwsR - rwsM
If x < 0 Then
.Rows(RW + 1 & ":" & RW - x).Delete
Else
.Rows(RW + 1 & ":" & RW + x).Insert
End If
Sheets("Raw").Cells(1, 1).CurrentRegion.Resize(, 2).Copy .Range("A" & RW)
MsgBox Selection.Address(1, 1, 1, 1)
.Activate
End With
Worksheets("Raw").Activate
End Sub
mdmackillop
07-28-2017, 07:14 AM
Thanks Paul
After I posted I saw that if I clicked cell highlighting the "real" selection was coloured.
Regards
Malcolm
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.