ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Split code in more than one page ? (https://www.excelbanter.com/excel-programming/350511-split-code-more-than-one-page.html)

SpookiePower

Split code in more than one page ?
 
I have made a pretty long page with VB code and now
I was thinking if it is possible to spilt the code over more
than just one page, and then inlcude the other pages into
the mainpage when ever they was needed ?


--
Mit fotoalbum
www.photo.activewebsite.dk



Peter Rooney

Split code in more than one page ?
 
Good morning!

Yes, it is possible to have several code pages - the key thing to remember
is to declare your variables appropriately - if you declare them on one
sheet, but want them to be available to procedures in another, you'll need to
declare them with PUBLIC and not with DIM. I usually have once code sheet
just for declarations, with no code at all, just to keep things tody.

Regards

Pete

"SpookiePower" wrote:

I have made a pretty long page with VB code and now
I was thinking if it is possible to spilt the code over more
than just one page, and then inlcude the other pages into
the mainpage when ever they was needed ?


--
Mit fotoalbum
www.photo.activewebsite.dk




SpookiePower

Split code in more than one page ?
 
"Peter Rooney" skrev i en meddelelse
...
Good morning!

Yes, it is possible to have several code pages - the key thing to remember
is to declare your variables appropriately - if you declare them on one
sheet, but want them to be available to procedures in another, you'll need to
declare them with PUBLIC and not with DIM. I usually have once code sheet
just for declarations, with no code at all, just to keep things tody.

Regards

Pete


Thanks, thats just what I was looking for, but who do
I create other pages ?



Peter Rooney

Split code in more than one page ?
 
In the VBA editor, click Insert-Module from the menu.
There is also a tool you can add to the toobar to do this - it's the third
one in the "Insert" category. Onse inserted, you can rename the modules by
highlighting their names in the "Properties" window.

Regards

Pete



"SpookiePower" wrote:

"Peter Rooney" skrev i en meddelelse
...
Good morning!

Yes, it is possible to have several code pages - the key thing to remember
is to declare your variables appropriately - if you declare them on one
sheet, but want them to be available to procedures in another, you'll need to
declare them with PUBLIC and not with DIM. I usually have once code sheet
just for declarations, with no code at all, just to keep things tody.

Regards

Pete


Thanks, thats just what I was looking for, but who do
I create other pages ?




SpookiePower

Split code in more than one page ?
 
"Peter Rooney" skrev i en meddelelse
...
In the VBA editor, click Insert-Module from the menu.
There is also a tool you can add to the toobar to do this - it's the third
one in the "Insert" category. Onse inserted, you can rename the modules by
highlighting their names in the "Properties" window.

Regards

Pete



Thanks :)




All times are GMT +1. The time now is 09:39 AM.

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