Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default question on macro

I am using the following macro to increase the value of a cell on a double
click how. I cannot make it work for columns c,d,e,and f. Can anyone offer
any solutions?

Private Sub Worksheet_BeforeDoubleClick(ByVal Target _
As Range, Cancel As Boolean)
If Target.Row = 1 Then Exit Sub
If Target.Column < 2 Then Exit Sub 'Require Col B
On Error Resume Next
Application.EnableEvents = False
Target.Value = Target.Value + 1
Application.EnableEvents = True
If Err.Number < 0 Then
MsgBox "Unable to add 1 to value in cell " _
& Target.Address(0, 0)
End If
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default question on macro

Change

If Target.Column < 2 Then Exit Sub 'Require Col B

to

If Target.Column < 3 Or Target.Column 7 Then Exit Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)


"kara" wrote in message
...
I am using the following macro to increase the value of a cell on a double
click how. I cannot make it work for columns c,d,e,and f. Can anyone

offer
any solutions?

Private Sub Worksheet_BeforeDoubleClick(ByVal Target _
As Range, Cancel As Boolean)
If Target.Row = 1 Then Exit Sub
If Target.Column < 2 Then Exit Sub 'Require Col B
On Error Resume Next
Application.EnableEvents = False
Target.Value = Target.Value + 1
Application.EnableEvents = True
If Err.Number < 0 Then
MsgBox "Unable to add 1 to value in cell " _
& Target.Address(0, 0)
End If
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default question on macro

Private Sub Worksheet_BeforeDoubleClick(ByVal Target _
As Range, Cancel As Boolean)
If Target.Row = 1 Then Exit Sub
If Target.Column < 2 or Target.column 6 Then Exit Sub 'Require Col B
On Error Resume Next
Application.EnableEvents = False
Target.Value = Target.Value + 1
Application.EnableEvents = True
If Err.Number < 0 Then
MsgBox "Unable to add 1 to value in cell " _
& Target.Address(0, 0)
End If
End Sub

--
Regards,
Tom Ogilvy


"kara" wrote in message
...
I am using the following macro to increase the value of a cell on a double
click how. I cannot make it work for columns c,d,e,and f. Can anyone

offer
any solutions?

Private Sub Worksheet_BeforeDoubleClick(ByVal Target _
As Range, Cancel As Boolean)
If Target.Row = 1 Then Exit Sub
If Target.Column < 2 Then Exit Sub 'Require Col B
On Error Resume Next
Application.EnableEvents = False
Target.Value = Target.Value + 1
Application.EnableEvents = True
If Err.Number < 0 Then
MsgBox "Unable to add 1 to value in cell " _
& Target.Address(0, 0)
End If
End Sub



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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2007 Macro/VB Question DDE Question MadDog22 Excel Worksheet Functions 1 March 10th 10 01:47 AM
Macro Question carl Excel Worksheet Functions 2 May 15th 07 07:23 PM
Macro Question Diana Excel Discussion (Misc queries) 1 July 15th 06 12:28 AM
MACRO QUESTION Eddy Stan Excel Worksheet Functions 2 February 28th 06 01:08 PM
one last macro question Michael A Excel Programming 0 March 7th 05 03:07 AM


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

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

About Us

"It's about Microsoft Excel"