Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 425
Default Highlight row and insert text on click

If user clicks on any cell in column J, i need for that cell to state
"done" and the active row (A:J) to highlight/change background to
gray.

If they click again, remove the highlight and word.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Highlight row and insert text on click

"J.W. Aldridge" wrote in message
...
If user clicks on any cell in column J, i need for that cell to state
"done" and the active row (A:J) to highlight/change background to
gray.

If they click again, remove the highlight and word.


Like 50% of anything I do, this is a *******ization of someone's
*******ization of Chip Pearson's code. I think it originally was meant as a
sheet change, rather than selection change. I'm sure there's a better way
to specify the J column (alert; I only went down to 65000), and there's also
no error handling for an accidental multiple selection; also, to make the
event work twice you have to click outside the cell and click back on it;
clicking on it once and then again without leaving it won't trigger the 2nd
event. Also keep in mind that this assumes you either want "Done" or
nothing; there's no allowing for other values when clicking in J.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.EnableEvents = False
If Not Application.Intersect(Target, Range("J1:J65000")) Is Nothing Then
If Selection.Value < "DONE" Then
Selection.Value = "DONE"
Range("A" & Selection.Row & ":J" & Selection.Row).Interior.ColorIndex =
56
Else
Selection.Value = ""
Range("A" & Selection.Row & ":J" & Selection.Row).Interior.ColorIndex =
xlNone
End If

End If
Application.EnableEvents = True
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 420
Default Highlight row and insert text on click

Excel doesn't really keep track of clicks this way. You can use the selection
change event, but that'll fire when the user uses the mouse or selects the cell
with his arrow keys.

Instead of using a click, you could use a rightclick or doubleclick event to do
the work.

This uses the beforerightclick event and goes in that sheet's module.

Option Explicit
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)

Dim RngToInspect As Range

If Target.Cells.Count 1 Then
Exit Sub 'one cell at a time
End If

Set RngToInspect = Me.Range("J1").EntireColumn

If Intersect(Target, RngToInspect) Is Nothing Then
Exit Sub
End If

Application.EnableEvents = False 'just in case
With Target
If LCase(Target.Value) = LCase("done") Then
'wipe it out
.Value = ""
.EntireRow.Range("A1:J1").Interior.ColorIndex = xlNone
Else
.Value = "done"
.EntireRow.Range("A1:J1").Interior.ColorIndex = 15
End If
End With
Application.EnableEvents = True

'stop rightclick menu from appearing
Cancel = True

End Sub

A colorindex of 15 was light gray in my workbook. You may want to record a
simple macro to see what the number is for your favorite shade of gray.


On 10/12/2010 10:38, J.W. Aldridge wrote:
If user clicks on any cell in column J, i need for that cell to state
"done" and the active row (A:J) to highlight/change background to
gray.

If they click again, remove the highlight and word.


--
Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 425
Default Highlight row and insert text on click

Thanx Guys!
When I make my first Million, I'm buying you both a Krystal (or White
Castle) with Cheese!
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to click and highlight cells and calculate the total amount in MS Excel? Bon Excel Programming 0 January 5th 07 01:13 PM
highlight with right click? Newbie Excel Programming 4 June 29th 06 05:37 PM
Highlight cells with ctrl-click but only un-highlight one cell hagan Excel Discussion (Misc queries) 5 May 27th 05 06:45 PM
Trap Right CLick Insert Von Shean Excel Programming 1 January 22nd 04 04:42 AM
is it possible to CLICK & insert date MIKE Excel Programming 9 January 6th 04 12:39 PM


All times are GMT +1. The time now is 12:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"