Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
I need a macro that fills in a cell with an "X" if I click it.
I'm trying to create a macro that I can apply to worksheets where I need to
classify terms into one or more categories. It would be great if I could just click in the cells that represent the category for each term instead of clicking and then hitting X. Thanks, Ivan |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
I need a macro that fills in a cell with an "X" if I click it.
Hi Ivan,
Try: '============= Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim Rng As Range Set Rng = Me.Range("A1:A100") '<<=== CHANGE Set Rng = Intersect(Rng, Target) If Not Rng Is Nothing Then On Error GoTo XIT Application.EnableEvents = False Rng.Value = "X" End If XIT: Application.EnableEvents = True End Sub '<<============= This is worksheet event code and should be pasted into the worksheets's code module (not a standard module and not the workbook's ThisWorkbook module): Right-click the worksheet's tab Select 'View Code' from the menu and paste the code. Alt-F11 to return to Excel. --- Regards, Norman "Ivan Laars" wrote in message ... I'm trying to create a macro that I can apply to worksheets where I need to classify terms into one or more categories. It would be great if I could just click in the cells that represent the category for each term instead of clicking and then hitting X. Thanks, Ivan |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
I need a macro that fills in a cell with an "X" if I click it.
Norman-
This worked like a charm and introduced me to a whole new world of Excel functionality! Thanks 10^6 -Ivan "Norman Jones" wrote: Hi Ivan, Try: '============= Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim Rng As Range Set Rng = Me.Range("A1:A100") '<<=== CHANGE Set Rng = Intersect(Rng, Target) If Not Rng Is Nothing Then On Error GoTo XIT Application.EnableEvents = False Rng.Value = "X" End If XIT: Application.EnableEvents = True End Sub '<<============= This is worksheet event code and should be pasted into the worksheets's code module (not a standard module and not the workbook's ThisWorkbook module): Right-click the worksheet's tab Select 'View Code' from the menu and paste the code. Alt-F11 to return to Excel. --- Regards, Norman "Ivan Laars" wrote in message ... I'm trying to create a macro that I can apply to worksheets where I need to classify terms into one or more categories. It would be great if I could just click in the cells that represent the category for each term instead of clicking and then hitting X. Thanks, Ivan |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
I need a macro that fills in a cell with an "X" if I click it.
Ivan
To have the code operate on all worksheets in the workbook you could alter Norman's code and place it in the Thisworkbook module. Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As _ Range) Dim Rng As Range Set Rng = ActiveSheet.Range("A1:A100") '<<=== CHANGE Set Rng = Intersect(Rng, Target) If Not Rng Is Nothing Then On Error GoTo XIT Application.EnableEvents = False Rng.Value = "X" End If XIT: Application.EnableEvents = True End Sub Gord Dibben MS Excel MVP On Mon, 9 Apr 2007 20:47:48 +0100, "Norman Jones" wrote: Hi Ivan, Try: '============= Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim Rng As Range Set Rng = Me.Range("A1:A100") '<<=== CHANGE Set Rng = Intersect(Rng, Target) If Not Rng Is Nothing Then On Error GoTo XIT Application.EnableEvents = False Rng.Value = "X" End If XIT: Application.EnableEvents = True End Sub '<<============= This is worksheet event code and should be pasted into the worksheets's code module (not a standard module and not the workbook's ThisWorkbook module): Right-click the worksheet's tab Select 'View Code' from the menu and paste the code. Alt-F11 to return to Excel. --- Regards, Norman "Ivan Laars" wrote in message ... I'm trying to create a macro that I can apply to worksheets where I need to classify terms into one or more categories. It would be great if I could just click in the cells that represent the category for each term instead of clicking and then hitting X. Thanks, Ivan |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell | Excel Discussion (Misc queries) | |||
"Control" plus "click" doesn't allow me to select multiple cells | New Users to Excel | |||
Automatically click "Update Links" & "Continue" | Excel Programming | |||
Worksheets("Brackets").DropDowns("Game10").Click | Excel Programming | |||
commnd button - when i rt click, "assign macro" isnt an option... | Excel Programming |