Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Reading a Range to an Array
Hi,
I am doing something wrong in trying to read a range from a spreadsheet into an array. Below are the relevant portions of my code. I have omitted the extraneous stuff. Sub UpdateSheet() '\Three string names Dim sSpreadShtNameRng As String '\Range Name1 Dim sPwdNameRng As String '\Range Name2 Dim sWriteResPwdNameRng As String '\Range Name3 Dim vaSpreadShtName As Variant Dim vaPwd As Variant Dim vaWriteResPwd As Variant Dim iCounter As Integer sHiddenFileName = "Hidden" '\ 3 range name are on the sheet "Hidden" '\ All ranges are local..but I tried global '\too and it failed. sSpreadShtNameRng = "xrnSpreadShtNameCC" '\Range Name1 sPwdNameRng = "xrnPwd1CC" ' \Range Name2 sWriteResPwdNameRng = "xrnPwd2CC" '\Range Name3 '\Activate Hidden sheet. Worksheets(sHiddenFileName).Activate '\ I think below is where I am going wrong... vaSpreadShtName = Range(sSpreadShtNameRng).Value vaPwd = Range(sPwdNameRng).Value vaWriteResPwd = Range(sPwdNameRng).Value '\ Below I get iCounter=1, but the next step yields an error message '\ Run-time error: 9, subscript out of range. For iCounter = 1 To 5 Step 1 Debug.Print iCounter Debug.Print vaSpreadShtName(iCounter) Debug.Print vaPwd(iCounter) Debug.Print vaWriteResPwd(iCounter) Next iCounter End Sub Can you see my error(s)? And if so, can you please shed some light on this matter for me. Thank you. Regards, Kevin |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Reading content of array formula | Excel Programming | |||
Reading a VBA Array - Thanks | Excel Programming | |||
Reading .csv file into array | Excel Programming | |||
reading an arbitrary selection into a 1D array | Excel Programming | |||
Reading a cell into an array | Excel Programming |