PC Review


Reply
Thread Tools Rate Thread

Bug - Programmatic copy/paste other sheet to activecell

 
 
=?Utf-8?B?R3JlZyBXaWxzb24=?=
Guest
Posts: n/a
 
      12th Apr 2007
Does anyone have an elegant fix to the following:
1. Put text in any cell in Sheet2, say cell A1.
2. Select a cell in Sheet1.
3. Run this code:
Sub Test()
Sheets(2).Range("A1").Copy ActiveCell
End Sub
4. Now select a different cell in Sheet1. I find that the black border
highlight of the former activecell (cell that was pasted to) acts in reverse
- i.e. if you select it, the black border goes blank and if you select a
differenct cell it receives a black border. Therefore, two cells now have
black borders.

You can fix it with a kludge:
Sub Test()
Sheets(2).Range("A1").Copy ActiveCell
ActiveCell.Copy ActiveCell
End Sub

You can also fix it by scrolling until the cell is off screen and then
scrolling back; or seleting a multicell range that completely contains the
affected cell, and then select the cell.

If I don't receive a better solution then this will at least serve as a bug
warning. Wondering if there is a more elegant solution (repainting?) or if
I'm missing something. Appreciative of your responses.

Greg


 
Reply With Quote
 
 
 
 
NickHK
Guest
Posts: n/a
 
      12th Apr 2007
Greg,
Yes, I see the same behaviour in XL2K & XL2002.
Seems to have been around for a while, possibly related to the mouse driver:
http://www.mvps.org/dmcritchie/excel/ghosting.txt

NickHK

"Greg Wilson" <(E-Mail Removed)> wrote in message
news:77B5CD49-05CA-4E7A-A0E1-(E-Mail Removed)...
> Does anyone have an elegant fix to the following:
> 1. Put text in any cell in Sheet2, say cell A1.
> 2. Select a cell in Sheet1.
> 3. Run this code:
> Sub Test()
> Sheets(2).Range("A1").Copy ActiveCell
> End Sub
> 4. Now select a different cell in Sheet1. I find that the black border
> highlight of the former activecell (cell that was pasted to) acts in

reverse
> - i.e. if you select it, the black border goes blank and if you select a
> differenct cell it receives a black border. Therefore, two cells now have
> black borders.
>
> You can fix it with a kludge:
> Sub Test()
> Sheets(2).Range("A1").Copy ActiveCell
> ActiveCell.Copy ActiveCell
> End Sub
>
> You can also fix it by scrolling until the cell is off screen and then
> scrolling back; or seleting a multicell range that completely contains the
> affected cell, and then select the cell.
>
> If I don't receive a better solution then this will at least serve as a

bug
> warning. Wondering if there is a more elegant solution (repainting?) or if
> I'm missing something. Appreciative of your responses.
>
> Greg
>
>



 
Reply With Quote
 
Incidental
Guest
Posts: n/a
 
      12th Apr 2007
Hi Greg

I'm not sure why excel would be doing that but it does it on my system
to. It will work if you pass the cell value to a string then put the
string to the activecell like the code below.

Option Explicit
Dim MyStr As String

Sub Test()
MyStr = Sheets(2).Range("A1")
ActiveCell.Value = MyStr
End Sub

Hope this is of some use to you.

S



 
Reply With Quote
 
=?Utf-8?B?R3JlZyBXaWxzb24=?=
Guest
Posts: n/a
 
      13th Apr 2007
Thanks Nick. I gusess my solution is as good as any other.

Greg

"NickHK" wrote:

> Greg,
> Yes, I see the same behaviour in XL2K & XL2002.
> Seems to have been around for a while, possibly related to the mouse driver:
> http://www.mvps.org/dmcritchie/excel/ghosting.txt
>
> NickHK
>
> "Greg Wilson" <(E-Mail Removed)> wrote in message
> news:77B5CD49-05CA-4E7A-A0E1-(E-Mail Removed)...
> > Does anyone have an elegant fix to the following:
> > 1. Put text in any cell in Sheet2, say cell A1.
> > 2. Select a cell in Sheet1.
> > 3. Run this code:
> > Sub Test()
> > Sheets(2).Range("A1").Copy ActiveCell
> > End Sub
> > 4. Now select a different cell in Sheet1. I find that the black border
> > highlight of the former activecell (cell that was pasted to) acts in

> reverse
> > - i.e. if you select it, the black border goes blank and if you select a
> > differenct cell it receives a black border. Therefore, two cells now have
> > black borders.
> >
> > You can fix it with a kludge:
> > Sub Test()
> > Sheets(2).Range("A1").Copy ActiveCell
> > ActiveCell.Copy ActiveCell
> > End Sub
> >
> > You can also fix it by scrolling until the cell is off screen and then
> > scrolling back; or seleting a multicell range that completely contains the
> > affected cell, and then select the cell.
> >
> > If I don't receive a better solution then this will at least serve as a

> bug
> > warning. Wondering if there is a more elegant solution (repainting?) or if
> > I'm missing something. Appreciative of your responses.
> >
> > Greg
> >
> >

>
>
>

 
Reply With Quote
 
=?Utf-8?B?R3JlZyBXaWxzb24=?=
Guest
Posts: n/a
 
      13th Apr 2007
Thanks for your response. Unfortunately I also need the formats and so
copying is the best option.

It appears to be caused by the copy/paste operation. You don't actually need
to pass the value to a variable. For example, this doesn't cause the problem:

ActiveCell.Value = Sheets("Sheet2").Range("A1").Value

while this does:

Sheets(2).Range("A1").Copy ActiveCell

Regards,
Greg

"Incidental" wrote:

> Hi Greg
>
> I'm not sure why excel would be doing that but it does it on my system
> to. It will work if you pass the cell value to a string then put the
> string to the activecell like the code below.
>
> Option Explicit
> Dim MyStr As String
>
> Sub Test()
> MyStr = Sheets(2).Range("A1")
> ActiveCell.Value = MyStr
> End Sub
>
> Hope this is of some use to you.
>
> S
>
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy and Paste Formula from ActiveCell to cells in 13 columns priorto the active column sgltaylor Microsoft Excel Programming 1 30th Nov 2009 10:33 AM
Copy Paste from Class Sheet to Filtered List on Combined Sheet prkhan56@gmail.com Microsoft Excel Programming 6 16th Sep 2008 04:30 PM
Help to code Macro to Copy fron one sheet and paste in other sheet kay Microsoft Excel Programming 3 25th Jul 2008 06:46 PM
copy the value of the activecell on sheet1 to the same address on sheet 2 Maxx Microsoft Excel Programming 2 5th Apr 2008 02:55 AM
automatic copy and paste from sheet to sheet in a workbook =?Utf-8?B?cmFtc2V5anJhbXNleWo=?= Microsoft Excel Programming 6 11th Dec 2004 12:37 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:14 AM.