Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Export 1-dimensional array values to a two-dimensional table? Laurie Excel Programming 2 November 8th 07 03:51 PM
Changing a two-dimensional, one row array to one-dimensional Alan Beban[_2_] Excel Programming 1 September 16th 07 08:56 PM
Store range of values in an array Trevor Shuttleworth Excel Programming 6 November 8th 06 06:37 AM
permutation of values in 2 dimensional array [email protected] Excel Programming 1 August 21st 06 08:36 PM
Create One-Dimensional Array from Two-Dimensional Array Stratuser Excel Programming 1 February 23rd 05 08:46 PM


All times are GMT +1. The time now is 08:58 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"