Need help defining variable in Visual Basic please

  Newuser3443 11:24 12 Oct 05
Locked

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.

Rob

  johnnyrocker 11:32 12 Oct 05

i think you are likely to get a much better response if you post in web design forum.


johnny.

  Newuser3443 11:33 12 Oct 05

will try there - thank you Johnny

  Simsy 12:40 12 Oct 05

the web design forum is NOT the place for this query???

Anyway...

You need to declare the variable first using the line;

Dim numsheets as Integer


The fact that you mention worksheets leads me to think that perhaps you are working in Excel, and in fact it is VBA you are using. Is that correct? (Not that it would make a difference to this specific question!)


Regards,

Simsy

  Monoux 12:44 12 Oct 05

You need to declare your variable as Public otherwise it will only operate within its own subroutine and its value will not be available to other routines.

  VoG II 21:36 12 Oct 05

You need to Dim it at the top of the module, before any Sub, Function etc.

If it is to be used by routines in other modules then you need to declare it as Public.

Is this VB or VBA?

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

Best phone camera 2016/2017: Galaxy S7 vs iPhone 7 vs Google Pixel vs HTC 10 Evo vs OnePlus 3T vs…

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

These are the Best Christmas Ads and Studio Projects of 2016

Super Mario Run preview | Hands-on first impressions of Super Mario Run: Mario's iPhone & iPad…