Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have this script
public tMonths Sub LoadMonths() Set shtMesi = Workbooks(w).Sheets(sht) LastRow = shtM.Cells.SpecialCells(xlCellTypeLastCell).Row LastCol = shtM.Cells(1, 255).End(xlToLeft).Column ReDim tMonths(LastRow, LastCol) For R = 1 To LastRow For C = 1 To LastCol tMonths(R, C) = shtMesi.Cells(R C) Next next end sub If i write this public tMonths Sub LoadMonths() Dim lRange As Range Dim tMonths as Variant Set lRange = workbooks(w).sheets(sht).Range(range) tMonths = lRange.value end sub and i try to call from another macro i get error using tMonths What do i wrong? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
First off I notice that you have declared tMonths both Public at the top of
the procedue and again within the procedure. The Dim tMonths will override the Public tMonths and your public variable will not be initialized. HTH "Circe" wrote: I have this script public tMonths Sub LoadMonths() Set shtMesi = Workbooks(w).Sheets(sht) LastRow = shtM.Cells.SpecialCells(xlCellTypeLastCell).Row LastCol = shtM.Cells(1, 255).End(xlToLeft).Column ReDim tMonths(LastRow, LastCol) For R = 1 To LastRow For C = 1 To LastCol tMonths(R, C) = shtMesi.Cells(R C) Next next end sub If i write this public tMonths Sub LoadMonths() Dim lRange As Range Dim tMonths as Variant Set lRange = workbooks(w).sheets(sht).Range(range) tMonths = lRange.value end sub and i try to call from another macro i get error using tMonths What do i wrong? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
First off I notice that you have declared tMonths both Public at the top
of the procedue and again within the procedure. The Dim tMonths will override the Public tMonths and your public variable will not be initialized. And how can i pass to another macro the array?? |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If you just declare it Public outside of the macro, and remove the same
variable in the macro, then the other macro can use that same macro. -- HTH RP (remove nothere from the email address if mailing direct) "Circe" wrote in message ... First off I notice that you have declared tMonths both Public at the top of the procedue and again within the procedure. The Dim tMonths will override the Public tMonths and your public variable will not be initialized. And how can i pass to another macro the array?? |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am having a little trouble following your answer Bob. Normally you are much
more lucid than I am. tMonths is global and can be read from or written to by any macro. So just remove the Dim statement and you are off to the races. HTH "Bob Phillips" wrote: If you just declare it Public outside of the macro, and remove the same variable in the macro, then the other macro can use that same macro. -- HTH RP (remove nothere from the email address if mailing direct) "Circe" wrote in message ... First off I notice that you have declared tMonths both Public at the top of the procedue and again within the procedure. The Dim tMonths will override the Public tMonths and your public variable will not be initialized. And how can i pass to another macro the array?? |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
okokokokokok !
i got it! thx! "Jim Thomlinson" ha scritto nel messaggio ... I am having a little trouble following your answer Bob. Normally you are much more lucid than I am. tMonths is global and can be read from or written to by any macro. So just remove the Dim statement and you are off to the races. HTH "Bob Phillips" wrote: If you just declare it Public outside of the macro, and remove the same variable in the macro, then the other macro can use that same macro. -- HTH RP (remove nothere from the email address if mailing direct) "Circe" wrote in message ... First off I notice that you have declared tMonths both Public at the top of the procedue and again within the procedure. The Dim tMonths will override the Public tMonths and your public variable will not be initialized. And how can i pass to another macro the array?? |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
:-).
I was just trying to reinforce your point Jim, but I think I had too many macros and too few variables. Regards Bob "Jim Thomlinson" wrote in message ... I am having a little trouble following your answer Bob. Normally you are much more lucid than I am. tMonths is global and can be read from or written to by any macro. So just remove the Dim statement and you are off to the races. HTH "Bob Phillips" wrote: If you just declare it Public outside of the macro, and remove the same variable in the macro, then the other macro can use that same macro. -- HTH RP (remove nothere from the email address if mailing direct) "Circe" wrote in message ... First off I notice that you have declared tMonths both Public at the top of the procedue and again within the procedure. The Dim tMonths will override the Public tMonths and your public variable will not be initialized. And how can i pass to another macro the array?? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Dim vs. Public | Excel Programming | |||
Array of Public Arrays | Excel Programming | |||
How to reference a public array (declared in module) from a proced | Excel Programming | |||
declaring a public array | Excel Programming | |||
Public Array | Excel Programming |