Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
how to store values in a 2 dimensional array
i want to store Sheet name and its corresponding password in a 2
dimension array . hope anyone can provide a code snippet for storing sheet name and its corresponding password and also code for popping out values from an array . i am newbie to vba . providin code wil be really helpful . i need something like i need to store the values in this fashion Array(0) ----- should contain sheetname and its password value Array(1) ----- should contain sheetname and its password value while popping out i shuld put the values in 2 variables . sheet name in Variable 1 its corresponding password in Password in Variable 2 ................ hope anyone can provide a code for this ........ |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
how to store values in a 2 dimensional array
hello. You can use this as a method for fulling up the 2 demitional array Code: -------------------- Sub FullArray() Dim ShtNm_Pass(1 To 4, 1 To 4): 'allowed for 4 sheets Dim x As Long With ThisWorkbook For x = 1 To 4 'Loading the sheet names ShtNm_Pass(x, 1) = .Sheets(x).Name 'if passwords are stored on a sheet (used the name hidden in this case) ShtNm_Pass(x, 2) = Sheets("Hidden").Cells(x, 1) Next x 'full the second half of the array (password manually) ' ShtNm_Pass(1, 2) = "1" ' ShtNm_Pass(2, 2) = "2" ' ShtNm_Pass(3, 2) = "3" ' ShtNm_Pass(4, 2) = "4" 'cheeking the array has been fulled. You dont need this only here for testing For x = LBound(ShtNm_Pass, 1) To UBound(ShtNm_Pass, 1) Debug.Print ShtNm_Pass(x, 1) Debug.Print ShtNm_Pass(x, 2) Next x End With End Sub -------------------- as the debug.print you can pull out the information form the array when ever you like. eg ShtNm_Pass(1, 1) would be the sheet name and ShtNm_Pass(1, 2) would be the corrosponding password. hope this helps -- D_Rennie ------------------------------------------------------------------------ D_Rennie's Profile: 1412 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=172487 Microsoft Office Help |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
how to store values in a 2 dimensional array
Since you're only keeping track of two things for each item, you don't need to
use "1 to 4" for each dimension. Dim ShtNm_Pass(1 To 4, 1 To 2) would be sufficient. D_Rennie wrote: hello. You can use this as a method for fulling up the 2 demitional array Code: -------------------- Sub FullArray() Dim ShtNm_Pass(1 To 4, 1 To 4): 'allowed for 4 sheets Dim x As Long With ThisWorkbook For x = 1 To 4 'Loading the sheet names ShtNm_Pass(x, 1) = .Sheets(x).Name 'if passwords are stored on a sheet (used the name hidden in this case) ShtNm_Pass(x, 2) = Sheets("Hidden").Cells(x, 1) Next x 'full the second half of the array (password manually) ' ShtNm_Pass(1, 2) = "1" ' ShtNm_Pass(2, 2) = "2" ' ShtNm_Pass(3, 2) = "3" ' ShtNm_Pass(4, 2) = "4" 'cheeking the array has been fulled. You dont need this only here for testing For x = LBound(ShtNm_Pass, 1) To UBound(ShtNm_Pass, 1) Debug.Print ShtNm_Pass(x, 1) Debug.Print ShtNm_Pass(x, 2) Next x End With End Sub -------------------- as the debug.print you can pull out the information form the array when ever you like. eg ShtNm_Pass(1, 1) would be the sheet name and ShtNm_Pass(1, 2) would be the corrosponding password. hope this helps -- D_Rennie ------------------------------------------------------------------------ D_Rennie's Profile: 1412 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=172487 Microsoft Office Help -- Dave Peterson |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
how to store values in a 2 dimensional array
cheers for pointing that out. I had it a little confused now understand :) -- D_Rennie ------------------------------------------------------------------------ D_Rennie's Profile: 1412 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=172487 Microsoft Office Help |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
how to store values in a 2 dimensional array
On Jan 23, 10:09*am, D_Rennie wrote:
cheers for pointing that out. I had it a little confused now understand :) -- D_Rennie ------------------------------------------------------------------------ D_Rennie's Profile: 1412 View this thread:http://www.thecodecage.com/forumz/sh...d.php?t=172487 Microsoft Office Help Thanks for that! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Export 1-dimensional array values to a two-dimensional table? | Excel Programming | |||
Changing a two-dimensional, one row array to one-dimensional | Excel Programming | |||
Store range of values in an array | Excel Programming | |||
permutation of values in 2 dimensional array | Excel Programming | |||
Create One-Dimensional Array from Two-Dimensional Array | Excel Programming |