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: 1,089
Default Store range of values in an array

I would like to save a range of values in an array for later processing.
The values are in cells A1 to N1. I'm using the following code to store the
data but, when I try to loop through the array, I immediately get a Run time
error '9': subscript out of range. The lower bound = 1 and the upper bound =
14 which is what I would expect. What am I doing wrong ?

Option Explicit
Option Base 1

Sub FormatChangeSheet()
Dim iColumn As Long
Dim aColumnWidth As Variant
Dim i As Long

'If ActiveWorkbook.Name = ThisWorkbook.Name Then Exit Sub

With ThisWorkbook.Sheets("Settings")
iColumn = .Range("IV1").End(xlToLeft).Column - 1
aColumnWidth = _
Application.Transpose( _
.Range(.Cells(1, 1), .Cells(1, iColumn)))
End With

For i = LBound(aColumnWidth) To UBound(aColumnWidth)
Debug.Print i & " " & aColumnWidth(i)
Next

End Sub


--

Thanks

Trevor



 
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
Store array ??? piero Excel Worksheet Functions 4 September 16th 09 04:39 PM
range values in an array? Mike Excel Programming 3 December 16th 05 04:56 PM
Lookup and store in array kanuvas[_7_] Excel Programming 1 November 9th 05 10:43 AM
Trying To Store Shapes/Objects to an array ?? Dan Thompson Excel Programming 0 September 21st 04 08:37 PM
read the values in a range and store them in macro Tom Ogilvy Excel Programming 0 September 13th 03 11:05 PM


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

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

About Us

"It's about Microsoft Excel"