Home |
Search |
Today's Posts |
#1
![]() |
|||
|
|||
![]()
I have built macros which are activated by a single cell selection in a worksheet (using a change event macro). I get an error if the user inadvertently selects more than one cell. My questions a
1. How can I prevent the user from selecting more than one cell on a particular worksheet? 2. What code will abort a macro if there is an error. Many Thanks Michael |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
#1. I like to start my worksheet_change procedures with code like:
if target.cells.count 1 then exit sub if intersect(target, me.range("a1:c9")) is nothing then exit sub Only one cell in the Range of A1:C9. #2. You could use the worksheet_selectionchange event. Option Explicit Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Cells.Count 1 Then Application.EnableEvents = False Target.Cells(1).Select Application.EnableEvents = True End If End Sub Michael Excel Dude wrote: I have built macros which are activated by a single cell selection in a worksheet (using a change event macro). I get an error if the user inadvertently selects more than one cell. My questions a 1. How can I prevent the user from selecting more than one cell on a particular worksheet? 2. What code will abort a macro if there is an error. Many Thanks Michael -- Michael Excel Dude -- Dave Peterson |
#3
![]() |
|||
|
|||
![]()
Dave, as always, you advice is flawless. Thanks very much.
---------------------------- Quote:
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
insert date | Excel Worksheet Functions | |||
?IF function for preventing a cell being filled by formula | Excel Worksheet Functions | |||
Line selection from a cell script through a VBA macro | Setting up and Configuration of Excel | |||
cell color index comparison | New Users to Excel | |||
Arrows move worksheet rather than cell selection, how fix? | Excel Worksheet Functions |