help defining variable in Visual Basic please.

  Newuser3443 11:34 12 Oct 05

I am using VB 6.3
I have a macro than calls a number of subroutines. The 1st macro includes the line.....

numsheets = sheets.count

which gives me the number of worksheets.

How do I declare numsheets as a variable so that I can use this result in the other subroutines?

I have very little experience of VB, so in the simplest terms possible please.

Thanks for reading this and for any assistance you can offer.

  tasslehoff burrfoot 23:13 12 Oct 05

I think it's

Public numsheets as Integer

But I'm probably wrong!

  Forum Editor 23:23 12 Oct 05

from WebDesign.

  VoG II 10:01 13 Oct 05

click here

I'm confused. Do you mean VBA in Excel?

All you need to do is insert the following at the top of the module

Dim numsheets

If you have more than one module and you need each of them to access numsheets then use

Public numsheets

  Newuser3443 20:36 13 Oct 05

Thanks again VoG, I do mean VBA (I didn't realise there was a difference).


This thread is now locked and can not be replied to.

Amazon Fire HD 8 review: A brilliant combination of function and value – with one massive caveat

1995-2015: How technology has changed the world in 20 years

How to create an introvert-friendly workplace

Apple Watch Series 2 review | Apple Watch 2 review: New Apple Watch is faster, brighter,…