jono19872006
Board Regular
- Joined
- Mar 13, 2012
- Messages
- 184
I have found the code below on the internet and currently use it in one of my sheets, essentially when you click in one of the cells in the range it puts a true value in that cell and then if you click again a false – like a tick box except this can be set up quickly for a long range when required.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
<o> </o>
Im not great with code and was wondering if anyone could help me to do any of the following two things, first how would I modify this code so that instead of a true/false value being entered into the cell a string of text of my choice was?<o></o>
<o> </o>
And secondly and less importantly the .Offset(0, 1).Select part of the code means that when you click on the cell and the value changes the curses then finishes on the adjacent cell, if I take this out then obviously it stays on the cell I have clicked on, however if I then click on the cell again the value doesn’t change until I click into a different cell and back again, eg if I take out the offset code then I click in C1 which changes to true, I click it again and nothing happens however if I click into D1 then back to C1 it changes to FALSE<o></o>
<o></o>
<o> </o>
Private Sub Worksheet_SelectionChange(ByVal Target As Range)<o></o>
With Target<o></o>
If (Not Application.Intersect(.Cells, Range("C1:C10")) Is Nothing) _<o></o>
And (.Cells.Count = 1) Then<o></o>
Application.EnableEvents = False<o></o>
.Value = Not (CStr(Target.Value) = "True")<o></o>
.Offset(0, 1).Select<o></o>
Application.EnableEvents = True<o></o>
End If<o></o>
End With<o></o>
End Sub<o></o>
<o> </o>
<o> </o>
Thanks Jon<o></o>
<o> </o>
Im not great with code and was wondering if anyone could help me to do any of the following two things, first how would I modify this code so that instead of a true/false value being entered into the cell a string of text of my choice was?<o></o>
<o> </o>
And secondly and less importantly the .Offset(0, 1).Select part of the code means that when you click on the cell and the value changes the curses then finishes on the adjacent cell, if I take this out then obviously it stays on the cell I have clicked on, however if I then click on the cell again the value doesn’t change until I click into a different cell and back again, eg if I take out the offset code then I click in C1 which changes to true, I click it again and nothing happens however if I click into D1 then back to C1 it changes to FALSE<o></o>
<o></o>
<o> </o>
Private Sub Worksheet_SelectionChange(ByVal Target As Range)<o></o>
With Target<o></o>
If (Not Application.Intersect(.Cells, Range("C1:C10")) Is Nothing) _<o></o>
And (.Cells.Count = 1) Then<o></o>
Application.EnableEvents = False<o></o>
.Value = Not (CStr(Target.Value) = "True")<o></o>
.Offset(0, 1).Select<o></o>
Application.EnableEvents = True<o></o>
End If<o></o>
End With<o></o>
End Sub<o></o>
<o> </o>
<o> </o>
Thanks Jon<o></o>