![]() |
public array
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? |
public array
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? |
public array
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?? |
public array
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?? |
public array
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?? |
public array
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?? |
public array
:-).
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?? |
All times are GMT +1. The time now is 01:38 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com