LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default 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
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
Reading content of array formula Papa Jonah Excel Programming 0 November 29th 04 06:45 PM
Reading a VBA Array - Thanks SMS - John Howard Excel Programming 0 October 30th 04 11:35 PM
Reading .csv file into array mousetrap Excel Programming 1 November 26th 03 07:47 AM
reading an arbitrary selection into a 1D array Jamie Martin[_2_] Excel Programming 5 September 30th 03 05:25 PM
Reading a cell into an array Tick-Tock Excel Programming 2 September 11th 03 07:33 PM


All times are GMT +1. The time now is 06:47 AM.

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"