View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
ghnogueira ghnogueira is offline
external usenet poster
 
Posts: 6
Default How to make a table with only one cell to be selected?

Works like a charm man! REALLY REALLY thanks! Just a question: is there any
way to make it work like if I had hit enter after typing the "x"? Right now
when I type the X on the box I have to either press enter or select a
different column for the script to run. Just a "lazyness" question =)

But as I don't know VB programming I'd like to learn a bit... I was looking
your code, and I couldn't identify where it says that only the "x" can do the
selection, since I tried with other stuff and it didn't work (not that I want
to, I just tested... x works as I wanted). I also didn't get where it
specifies that I can have two X's, one in each column, but not 2 x's in the
same column, or how the x in the first column doesn't exclude the x in the
second column.

Thanks in advance!





"vezerid" wrote:

You can use the following VBA event procedure for this:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A2:B13")) Is Nothing Then
v = Target.Value
col = Target.Column
Application.EnableEvents = False
Range(ActiveSheet.Cells(2, col), ActiveSheet.Cells(13,
col)).ClearContents
Target.Value = v
Application.EnableEvents = True
End If
End Sub

To install: Right click on the sheet tab. Choose View Code... This
takes you to the VBA IDE.
Paste the above code in the window. It should operate like you want
from this point on.

HTH
Kostis Vezerides