ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   double click a cell and add 1 to that cess (https://www.excelbanter.com/excel-discussion-misc-queries/19130-double-click-cell-add-1-cess.html)

cwwolfdog

double click a cell and add 1 to that cess
 
I need code to add 1 to a tally sheet in certain cells. The sheet has a
bunch of differenct cells that are seperate. Meaning a range of A1:F18 and
then a different range of A55:G81. There are about 4 different ranges or
group of cells that I need the user to be able to doubleclick if they wish to
add 1 to the current value in that cell. Any help is appreciated.

Chip Pearson

Right click the worksheet tab and choose View Code. In the code
module that is displayed, paste the following code:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range,
Cancel As Boolean)
Dim Rng As Range
Set Rng = Range("A1:F18", "A55:G81") ' add more ranges as
necessary
If Not Application.Intersect(Rng, Target) Is Nothing Then
Application.EnableEvents = False
Target.Value = Target.Value + 1
Application.EnableEvents = True
Cancel = True
End If
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"cwwolfdog" wrote in
message
...
I need code to add 1 to a tally sheet in certain cells. The
sheet has a
bunch of differenct cells that are seperate. Meaning a range
of A1:F18 and
then a different range of A55:G81. There are about 4 different
ranges or
group of cells that I need the user to be able to doubleclick
if they wish to
add 1 to the current value in that cell. Any help is
appreciated.




cwwolfdog

Chip, thanks for the info, but I am getting an error message.

Set Rng = Range("B5:F18", "B20:F24", "B103:G115", "B205:F210", "B213:F220",
"B223:F230", "B233:F240", "C304:G322", "C324:G328")

The error message says wrong number of arguments as soon as I put the third
range statement in there. I found this out by trial and error.

I am sure that I am doing something wrong.


"Chip Pearson" wrote:

Right click the worksheet tab and choose View Code. In the code
module that is displayed, paste the following code:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range,
Cancel As Boolean)
Dim Rng As Range
Set Rng = Range("A1:F18", "A55:G81") ' add more ranges as
necessary
If Not Application.Intersect(Rng, Target) Is Nothing Then
Application.EnableEvents = False
Target.Value = Target.Value + 1
Application.EnableEvents = True
Cancel = True
End If
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"cwwolfdog" wrote in
message
...
I need code to add 1 to a tally sheet in certain cells. The
sheet has a
bunch of differenct cells that are seperate. Meaning a range
of A1:F18 and
then a different range of A55:G81. There are about 4 different
ranges or
group of cells that I need the user to be able to doubleclick
if they wish to
add 1 to the current value in that cell. Any help is
appreciated.





Dave Peterson

Try:

Set rng = Range("B5:F18,B20:F24,B103:G115,B205:F210,B213:F22 0," & _
"B223:F230,B233:F240,C304:G322,C324:G328")

You can put it all on one line, but it looks pretty bad when it wraps in the
newsgroup.



cwwolfdog wrote:

Chip, thanks for the info, but I am getting an error message.

Set Rng = Range("B5:F18", "B20:F24", "B103:G115", "B205:F210", "B213:F220",
"B223:F230", "B233:F240", "C304:G322", "C324:G328")

The error message says wrong number of arguments as soon as I put the third
range statement in there. I found this out by trial and error.

I am sure that I am doing something wrong.

"Chip Pearson" wrote:

Right click the worksheet tab and choose View Code. In the code
module that is displayed, paste the following code:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range,
Cancel As Boolean)
Dim Rng As Range
Set Rng = Range("A1:F18", "A55:G81") ' add more ranges as
necessary
If Not Application.Intersect(Rng, Target) Is Nothing Then
Application.EnableEvents = False
Target.Value = Target.Value + 1
Application.EnableEvents = True
Cancel = True
End If
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"cwwolfdog" wrote in
message
...
I need code to add 1 to a tally sheet in certain cells. The
sheet has a
bunch of differenct cells that are seperate. Meaning a range
of A1:F18 and
then a different range of A55:G81. There are about 4 different
ranges or
group of cells that I need the user to be able to doubleclick
if they wish to
add 1 to the current value in that cell. Any help is
appreciated.





--

Dave Peterson


All times are GMT +1. The time now is 02:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com