PC Review


Reply
Thread Tools Rate Thread

detect ctrl-c was pressed (in copy mode) from vba?

 
 
Mad Scientist Jr
Guest
Posts: n/a
 
      27th Oct 2006
I am using color banding to highlight active cells as explained here:

Use color banding to locate the active cell
http://office.microsoft.com/en-us/as...366231033.aspx

which I altered to highlight only horizontally, the current row from
cols A to Z

However, this has a side effect where if you press ctrl-c to copy a
cell or range of cells, and then click on a destination cell, ctrl-v no
longer pastes because the color banding code deselects the cells.

Is there a way to detect that ctrl-c has been pressed and excel is in
"copy mode" to disable the color banding, and then re-enable it after
the cells are pasted?

 
Reply With Quote
 
 
 
 
Sandy
Guest
Posts: n/a
 
      27th Oct 2006
Try playing around with this:

In your Worksheet_SelectionChange code place this at the beginning:

If Application.CutCopyMode = 1 Or _
Application.CutCopyMode = 2 Then
Call DisableBanding
End If

Then insert a new module and paste this to it:

Sub DisableBanding()
While Application.CutCopyMode = 1 Or _
Application.CutCopyMode = 2
Application.EnableEvents = False
DoEvents
Wend
Application.EnableEvents = True
End Sub


Sandy


Mad Scientist Jr wrote:
> I am using color banding to highlight active cells as explained here:
>
> Use color banding to locate the active cell
> http://office.microsoft.com/en-us/as...366231033.aspx
>
> which I altered to highlight only horizontally, the current row from
> cols A to Z
>
> However, this has a side effect where if you press ctrl-c to copy a
> cell or range of cells, and then click on a destination cell, ctrl-v no
> longer pastes because the color banding code deselects the cells.
>
> Is there a way to detect that ctrl-c has been pressed and excel is in
> "copy mode" to disable the color banding, and then re-enable it after
> the cells are pasted?


 
Reply With Quote
 
=?Utf-8?B?SmltIFRob21saW5zb24=?=
Guest
Posts: n/a
 
      27th Oct 2006
Right from the article you posted...

There are two drawbacks to this method. First, as mentioned above, it is not
appropriate if you already have conditional formats. Second, the code tends
to clear the clipboard, so it becomes virtually impossible to copy and paste
while this code is running.

You can get the row liner addin from Chip if that helps...

http://www.cpearson.com/excel/RowLiner.htm
--
HTH...

Jim Thomlinson


"Mad Scientist Jr" wrote:

> I am using color banding to highlight active cells as explained here:
>
> Use color banding to locate the active cell
> http://office.microsoft.com/en-us/as...366231033.aspx
>
> which I altered to highlight only horizontally, the current row from
> cols A to Z
>
> However, this has a side effect where if you press ctrl-c to copy a
> cell or range of cells, and then click on a destination cell, ctrl-v no
> longer pastes because the color banding code deselects the cells.
>
> Is there a way to detect that ctrl-c has been pressed and excel is in
> "copy mode" to disable the color banding, and then re-enable it after
> the cells are pasted?
>
>

 
Reply With Quote
 
Shailesh Shah
Guest
Posts: n/a
 
      28th Oct 2006
You can also download workbook navigation addins from Excel Add-ins page
of below site.

http://in.geocities.com/shahshaileshs/


You can clik the options "Start Highliting Row". To Copy range of cells
select it with mouse, Copy & select the destination of range of cells
also with mouse & paste. To copy single cell, You need to terminate the
macro by "Stop Higlighting Row". Undo\Redo also works with this feature
on.

Regards,
Shah Shailesh
http://in.geocities.com/shahshaileshs/
(Excel Add-ins Page)

*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
gimme_this_gimme_that@yahoo.com
Guest
Posts: n/a
 
      29th Oct 2006
Thought I'd tag this.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim iColor As Integer

'// Note: Don't use if you have conditional
'// formatting that you want to keep

'// On error resume in case user selects a range of cells
On Error Resume Next
iColor = Target.Interior.ColorIndex

'// Leave On Error ON for Row offset errors
If iColor < 0 Then
iColor = 36
Else
iColor = iColor + 1
End If

'// Need this test in case Font color is the same
If iColor = Target.Font.ColorIndex Then iColor = iColor + 1
Cells.FormatConditions.Delete

'// Horizontal color banding
With Range("A" & Target.Row, Target.Address) 'Rows(Target.Row)
.FormatConditions.Add Type:=2, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = iColor
End With

'// Vertical color banding
With Range(Target.Offset(1 - Target.Row, 0).Address & ":" & _
Target.Offset(-1, 0).Address) 'Rows(Target.Row)
.FormatConditions.Add Type:=2, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = iColor
End With

End Sub

 
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
What really happens when Ctrl Alt Del is pressed? Jimmy Windows XP General 1 3rd Sep 2008 01:21 PM
detect ctrl-c was pressed (in copy mode) from vba? Mad Scientist Jr Microsoft Excel Misc 3 29th Oct 2006 06:34 AM
How can I detect if the CTRL key is pressed when User click on a control ? Steph. Microsoft C# .NET 2 3rd Jan 2006 04:56 PM
How to tell if Ctrl is pressed ...? Du Microsoft C# .NET 2 26th Jan 2005 02:22 PM
Best way to see if CTRL is being pressed? Baseman Microsoft C# .NET 2 17th Jul 2003 03:33 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:40 AM.