Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Sub to ensure a single, latest input of "x" in col G

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Sub to ensure a single, latest input of "x" in col G

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   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Sub to ensure a single, latest input of "x" in col G

Great! Works well.
Many thanks, Rick
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Sub to ensure a single, latest input of "x" in col G

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   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Sub to ensure a single, latest input of "x" in col G

Even better, thanks for the refinements!
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
Whats wrong with this? MyWBAccRep.Sheets("Volumes").Cells.Find("latest").Copy.Offset(0, Simon[_2_] Excel Programming 2 August 11th 08 01:29 PM
Multiple "source" workbooks linked to single "destination" workboo DAVEJAY Excel Worksheet Functions 1 September 17th 07 05:33 PM
Change default in input box from "20" to "000000"? Have macro continue on to name sheet tab? StargateFanFromWork[_4_] Excel Programming 7 October 29th 06 11:46 AM
bunch of "yes" or "no" entered in row, output 1 if a single yes dan2201 Excel Worksheet Functions 9 September 7th 06 05:05 PM
How to ensure that very large blocks of text "wrap" in a cell? nicholson61 Excel Discussion (Misc queries) 1 October 19th 05 05:18 PM


All times are GMT +1. The time now is 10:15 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"