#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 189
Default msgbox in VBA

hi,
how can I write a code by which when only a cell like D11, is selected, a
msgbox pops up?
thanx
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,101
Default msgbox in VBA

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If ActiveCell.Address < Range("D11").Address Then Exit Sub
MsgBox "Cell D11 is selected"
End Sub

"peyman" wrote:

hi,
how can I write a code by which when only a cell like D11, is selected, a
msgbox pops up?
thanx

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 189
Default msgbox in VBA

thanks Mike.that's great.I have one more question.what's the difference
between "worksheet code module" and "standard code module"?what codes are
usually posted in "standard module"?
thank you again

"Mike" wrote:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If ActiveCell.Address < Range("D11").Address Then Exit Sub
MsgBox "Cell D11 is selected"
End Sub

"peyman" wrote:

hi,
how can I write a code by which when only a cell like D11, is selected, a
msgbox pops up?
thanx

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default msgbox in VBA

Worksheet module is the code module behind a worksheet, it is a specific
type of class module. Typically, it is where you add code specific to that
worksheet, such as the worksheet event code that you were given.

A standard code module is where you add procedures that are more generic, or
need to be accessed from multiple places.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"peyman" wrote in message
...
thanks Mike.that's great.I have one more question.what's the difference
between "worksheet code module" and "standard code module"?what codes are
usually posted in "standard module"?
thank you again

"Mike" wrote:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If ActiveCell.Address < Range("D11").Address Then Exit Sub
MsgBox "Cell D11 is selected"
End Sub

"peyman" wrote:

hi,
how can I write a code by which when only a cell like D11, is selected,
a
msgbox pops up?
thanx



  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 189
Default msgbox in VBA

thank you Bob, but can you make an example for standard module code?

"Bob Phillips" wrote:

Worksheet module is the code module behind a worksheet, it is a specific
type of class module. Typically, it is where you add code specific to that
worksheet, such as the worksheet event code that you were given.

A standard code module is where you add procedures that are more generic, or
need to be accessed from multiple places.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"peyman" wrote in message
...
thanks Mike.that's great.I have one more question.what's the difference
between "worksheet code module" and "standard code module"?what codes are
usually posted in "standard module"?
thank you again

"Mike" wrote:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If ActiveCell.Address < Range("D11").Address Then Exit Sub
MsgBox "Cell D11 is selected"
End Sub

"peyman" wrote:

hi,
how can I write a code by which when only a cell like D11, is selected,
a
msgbox pops up?
thanx






  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,101
Default msgbox in VBA

Put this into a standard module
Sub exampleforstandardmodulecode()
If ActiveCell.Address < Range("D11").Address Then Exit Sub
MsgBox "Cell D11 is selected"
End Sub
Put this into a Thisworkbook module
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Range)
Run "exampleforstandardmodulecode"
End Sub

Now for every sheet in workbook when D11 is selected your msgbox will pop up

"peyman" wrote:

thank you Bob, but can you make an example for standard module code?

"Bob Phillips" wrote:

Worksheet module is the code module behind a worksheet, it is a specific
type of class module. Typically, it is where you add code specific to that
worksheet, such as the worksheet event code that you were given.

A standard code module is where you add procedures that are more generic, or
need to be accessed from multiple places.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"peyman" wrote in message
...
thanks Mike.that's great.I have one more question.what's the difference
between "worksheet code module" and "standard code module"?what codes are
usually posted in "standard module"?
thank you again

"Mike" wrote:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If ActiveCell.Address < Range("D11").Address Then Exit Sub
MsgBox "Cell D11 is selected"
End Sub

"peyman" wrote:

hi,
how can I write a code by which when only a cell like D11, is selected,
a
msgbox pops up?
thanx




  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 189
Default msgbox in VBA

than you MIke.got it.

"Mike" wrote:

Put this into a standard module
Sub exampleforstandardmodulecode()
If ActiveCell.Address < Range("D11").Address Then Exit Sub
MsgBox "Cell D11 is selected"
End Sub
Put this into a Thisworkbook module
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Range)
Run "exampleforstandardmodulecode"
End Sub

Now for every sheet in workbook when D11 is selected your msgbox will pop up

"peyman" wrote:

thank you Bob, but can you make an example for standard module code?

"Bob Phillips" wrote:

Worksheet module is the code module behind a worksheet, it is a specific
type of class module. Typically, it is where you add code specific to that
worksheet, such as the worksheet event code that you were given.

A standard code module is where you add procedures that are more generic, or
need to be accessed from multiple places.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"peyman" wrote in message
...
thanks Mike.that's great.I have one more question.what's the difference
between "worksheet code module" and "standard code module"?what codes are
usually posted in "standard module"?
thank you again

"Mike" wrote:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If ActiveCell.Address < Range("D11").Address Then Exit Sub
MsgBox "Cell D11 is selected"
End Sub

"peyman" wrote:

hi,
how can I write a code by which when only a cell like D11, is selected,
a
msgbox pops up?
thanx



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
msgbox peyman Excel Discussion (Misc queries) 5 October 4th 07 09:56 PM
MsgBox bumper338 Excel Discussion (Misc queries) 1 December 22nd 06 11:32 PM
MsgBox CC Excel Discussion (Misc queries) 4 May 5th 06 05:45 PM
msgbox James Coughlan Excel Discussion (Misc queries) 3 May 3rd 06 01:57 PM
msgbox flow23 Excel Discussion (Misc queries) 0 January 10th 06 03:25 PM


All times are GMT +1. The time now is 03:31 AM.

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"