ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   HELP! Object specific Code (https://www.excelbanter.com/excel-programming/323014-help-object-specific-code.html)

DEE

HELP! Object specific Code
 
Hi,

Am trying to understand VBA object code. I know that the Modules folders
contain sub routines for that workbook project.

I also noted that you can have code windows open for a particular worksheet.
When I click on the down arrow and select General, this code appears
automatically:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

End Sub

What does this mean?

--
Thanks!

Dee

Tom Ogilvy

HELP! Object specific Code
 
It is the selectionchange event for that worksheet. It fires whenever the
user selects a cell

http://www.cpearson.com/excel/events.htm
Chip Pearson's page on events (assuming it is back up - seemed to be down
earlier)
--
Regards,
Tom Ogilvy

"dee" wrote in message
...
Hi,

Am trying to understand VBA object code. I know that the Modules folders
contain sub routines for that workbook project.

I also noted that you can have code windows open for a particular

worksheet.
When I click on the down arrow and select General, this code appears
automatically:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

End Sub

What does this mean?

--
Thanks!

Dee




DEE

HELP! Object specific Code
 
Hi Tom,

Thanks for your help! So, I can write code that is stores in the Modules
folder that makes the sub available to all sheets in that workbook only
(unless written in the Modules folder of the Personal folder), OR I can write
code that is specific to only a particular worksheet.

The code is simply stored in the workbook code window; it doesn't have a
container like modules do (being placed in a modules folder)

Are these assumptions correct?

Thanks again!

"Tom Ogilvy" wrote:

It is the selectionchange event for that worksheet. It fires whenever the
user selects a cell

http://www.cpearson.com/excel/events.htm
Chip Pearson's page on events (assuming it is back up - seemed to be down
earlier)
--
Regards,
Tom Ogilvy

"dee" wrote in message
...
Hi,

Am trying to understand VBA object code. I know that the Modules folders
contain sub routines for that workbook project.

I also noted that you can have code windows open for a particular

worksheet.
When I click on the down arrow and select General, this code appears
automatically:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

End Sub

What does this mean?

--
Thanks!

Dee





Tom Ogilvy

HELP! Object specific Code
 
If you do Insert=Module you will get an entry under the modules entry in
the project explorer. Code in these modules are available to all code
within that workbook as long as the module is not declared as private or an
individual procedure is declared as private (this is true whether the
workbook is the personal workbook or not -- there is nothing special about
the personal workbook with respect to this).

Each worksheet has a corresponding module. these modules are used to
support sheet level events that can be selected/declared by using the
dropdowns at the top. This code reacts to actions by the user on that
sheet. Performing the action triggers the event code.

Similar there is a workbook level module. In the project explorer it is
shown as the ThisWorkbook module. It supports code for Workbook level
events.

Unless you are writing event code, you should be working in a general
module.

There is a similar situation with a userform. A module is associated with
the userform like a module is associated with a sheet. In fact, these
associated modules are special predefined Class modules.

You may also create you own classes using class modules.

--
Regards,
Tom Ogilvy

"dee" wrote in message
...
Hi Tom,

Thanks for your help! So, I can write code that is stores in the Modules
folder that makes the sub available to all sheets in that workbook only
(unless written in the Modules folder of the Personal folder), OR I can

write
code that is specific to only a particular worksheet.

The code is simply stored in the workbook code window; it doesn't have a
container like modules do (being placed in a modules folder)

Are these assumptions correct?

Thanks again!

"Tom Ogilvy" wrote:

It is the selectionchange event for that worksheet. It fires whenever

the
user selects a cell

http://www.cpearson.com/excel/events.htm
Chip Pearson's page on events (assuming it is back up - seemed to be

down
earlier)
--
Regards,
Tom Ogilvy

"dee" wrote in message
...
Hi,

Am trying to understand VBA object code. I know that the Modules

folders
contain sub routines for that workbook project.

I also noted that you can have code windows open for a particular

worksheet.
When I click on the down arrow and select General, this code appears
automatically:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

End Sub

What does this mean?

--
Thanks!

Dee








All times are GMT +1. The time now is 10:33 AM.

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