Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
cwwolfdog
 
Posts: n/a
Default 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.
  #2   Report Post  
Chip Pearson
 
Posts: n/a
Default

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.



  #3   Report Post  
cwwolfdog
 
Posts: n/a
Default

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.




  #4   Report Post  
Dave Peterson
 
Posts: n/a
Default

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
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



All times are GMT +1. The time now is 06:11 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"