Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / October 2008

Tip: Looking for answers? Try searching our database.

Referring to BeforeDoubleClick

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
art - 12 Oct 2008 21:58 GMT
Hello All:

I have a VBA Code Using the BeforeDoubleClick.
My Question is how do I refer to that Sub?

I want to make that if the user selects from a userform option 1 then
BeforeDoubleClick should one way, if user selects option 2 then
BeforeDoubleClick should work differently. Is there a way to do this? How Can
I do this? Below are the BeforeDoubleClick code and the userform code that I
want to use.

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
Cancel As Boolean)
If Target.Cells.Count > 1 Then Exit Sub

Cancel = True 'stop editing in cell
If IsNumeric(Target.Value) Then
Target.Value = Target.Value + 1
End If
End Sub

Private Sub OKButton_Click()
   On Error Resume Next
   If optionRightAdd Then
   Run Macro50
   End If
   If OptionLeftAdd Then
   Run Macro51
   End If
   Unload UserForm1
End Sub

Thanks in Advance.
Dave Peterson - 12 Oct 2008 22:26 GMT
You could create a public variable in a General module -- not behind the
worksheet and not in the userform's code.

Public myOption as long 'or boolean

Then change that value to whatever you need in the code for the userform.

Then you can check that variable's value in your event code:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
                                          Cancel As Boolean)
If Target.Cells.Count > 1 Then Exit Sub

Cancel = True 'stop editing in cell

if myoption = 1 then
  'do the stuff for option 1
else
  'do the stuff for option 2
end if

End Sub

> Hello All:
>
[quoted text clipped - 29 lines]
>
> Thanks in Advance.

Signature

Dave Peterson

art - 13 Oct 2008 00:46 GMT
Thanks for your help, but I don't understand exactly.
I assume that you want to make MyOptions public.
But where do I put in What?

I have the Userform code and the Module code containing the
BeforeDoubleClick Code. Now, what do I do now? What should I place in the new
module which code? And What should I change in the other ones?

Thanks for your help. Please help me thru, until the end.

Thanks again.

> You could create a public variable in a General module -- not behind the
> worksheet and not in the userform's code.
[quoted text clipped - 52 lines]
> >
> > Thanks in Advance.
Dave Peterson - 13 Oct 2008 01:21 GMT
I'm not sure I understand.

You'd still make the variable public and put it in a General module.

Then in the userform code:

Private Sub OKButton_Click()
   On Error Resume Next
   If optionRightAdd Then
      myOption = 1
      Run Macro50
   End If
   If OptionLeftAdd Then
      myoption = 2
      Run Macro51
   End If
   Unload UserForm1
End Sub

Then the _BeforeDoubleclick would use that variable (like in the previous post).

> Thanks for your help, but I don't understand exactly.
> I assume that you want to make MyOptions public.
[quoted text clipped - 68 lines]
> >
> > Dave Peterson

Signature

Dave Peterson

art - 13 Oct 2008 01:46 GMT
Can you please tell me the full code that I should put in the General module
to make the variable public and put it in a General module?

Thanks for your help.

> I'm not sure I understand.
>
[quoted text clipped - 89 lines]
> > >
> > > Dave Peterson
Dave Peterson - 13 Oct 2008 03:20 GMT
Public myOption as long 'or boolean

> Can you please tell me the full code that I should put in the General module
> to make the variable public and put it in a General module?
[quoted text clipped - 98 lines]
> >
> > Dave Peterson

Signature

Dave Peterson

art - 13 Oct 2008 03:46 GMT
Thanks I finally got it.

> Public myOption as long 'or boolean
>
[quoted text clipped - 100 lines]
> > >
> > > Dave Peterson
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.