Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Looking for a sub which can ensure that only a single, latest "x" can be
input at any one time within col G. If say, G2 already contains: x, and I input another: "x" into G4, the sub should clear G2 before accepting G4's input. Something like a toggle. Thanks |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Assuming the only text in Column G is to be this single X, then this event
code should do what you want... Private Sub Worksheet_Change(ByVal Target As Range) If Target.Column = 7 Then Application.EnableEvents = False Columns("G").Clear Target.Value = "X" Application.EnableEvents = True End If End Sub To install it, right click the tab at the bottom of the worksheet that is to have this functionality, select View Code from the popup menu that appears and then copy/paste the above code into the code window that opened up. Now go back to the worksheet and type in your X (actually, as written, any text will do) in any cell in Column G, then put the X in a cell in Column G. -- Rick (MVP - Excel) "Max" wrote in message ... Looking for a sub which can ensure that only a single, latest "x" can be input at any one time within col G. If say, G2 already contains: x, and I input another: "x" into G4, the sub should clear G2 before accepting G4's input. Something like a toggle. Thanks |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Great! Works well.
Many thanks, Rick |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This might be slightly better to use...
Private Sub Worksheet_Change(ByVal Target As Range) If Target.Column = 7 And Target.Count = 1 Then Application.EnableEvents = False Columns("G").Clear Target.Value = "X" Application.EnableEvents = True End If End Sub It protects your user selecting a series of cells in Column G and hitting the Delete button (doing that with my originally posted code will fill all the selected cells with X's). -- Rick (MVP - Excel) "Max" wrote in message ... Great! Works well. Many thanks, Rick |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Even better, thanks for the refinements!
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Whats wrong with this? MyWBAccRep.Sheets("Volumes").Cells.Find("latest").Copy.Offset(0, | Excel Programming | |||
Multiple "source" workbooks linked to single "destination" workboo | Excel Worksheet Functions | |||
Change default in input box from "20" to "000000"? Have macro continue on to name sheet tab? | Excel Programming | |||
bunch of "yes" or "no" entered in row, output 1 if a single yes | Excel Worksheet Functions | |||
How to ensure that very large blocks of text "wrap" in a cell? | Excel Discussion (Misc queries) |