Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default question about creating array

Hello group,

What's a better way to create an array like this?

Dim arrFieldInfo As Variant
arrFieldInfo = Array(Array(1, 2),Array(2, 2),Array(3, 2),Array(4,
2),Array(5, 2),Array(6, 2),Array(7, 2),Array(8, 2),Array(9,
2),Array(10, 2),Array(11, 2),Array(12, 2),Array(13, 2),Array(14,
2),Array(15, 2),Array(16, 2),Array(17, 2), Array(18,2),Array(19,
2),Array(20, 2),Array(21, 2),Array(22, 2), Array(23, 2), Array(24,
2),Array(25, 2),Array(26, 2),Array(27, 2),Array(28, 2),
Array(29, 2),Array(30, 2),Array(31, 2),Array(32, 2))

Thans for your help.

wcc

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 266
Default question about creating array

"wcc" skrev i en meddelelse
oups.com...
Hello group,

What's a better way to create an array like this?

Dim arrFieldInfo As Variant
arrFieldInfo = Array(Array(1, 2),Array(2, 2),Array(3, 2),Array(4,
2),Array(5, 2),Array(6, 2),Array(7, 2),Array(8, 2),Array(9,
2),Array(10, 2),Array(11, 2),Array(12, 2),Array(13, 2),Array(14,
2),Array(15, 2),Array(16, 2),Array(17, 2), Array(18,2),Array(19,
2),Array(20, 2),Array(21, 2),Array(22, 2), Array(23, 2), Array(24,
2),Array(25, 2),Array(26, 2),Array(27, 2),Array(28, 2),
Array(29, 2),Array(30, 2),Array(31, 2),Array(32, 2))

Thans for your help.

wcc


Hi wcc

Do you mean something like this?
After running the routine the array NewArray() holds the
values from arrFieldInfo.

Sub test45()
'Leo Heuser, 6 August 2006
Dim arrFieldInfo As Variant
Dim Counter As Long
Dim NewArray() As Variant

arrFieldInfo = Array(Array(1, 2), Array(2, 2), Array(3, 2), _
Array(4, 2), Array(5, 2), Array(6, 2), Array(7, 2), Array(8, 2), _
Array(9, 2), Array(10, 2), Array(11, 2), Array(12, 2), Array(13, 2), _
Array(14, 2), Array(15, 2), Array(16, 2), Array(17, 2), Array(18, 2), _
Array(19, 2), Array(20, 2), Array(21, 2), Array(22, 2), Array(23, 2), _
Array(24, 2), Array(25, 2), Array(26, 2), Array(27, 2), Array(28, 2), _
Array(29, 2), Array(30, 2), Array(31, 2), Array(32, 2))

ReDim NewArray(LBound(arrFieldInfo) To UBound(arrFieldInfo), _
LBound(arrFieldInfo) To LBound(arrFieldInfo) + 1)

For Counter = LBound(NewArray, 1) To UBound(NewArray, 1)
NewArray(Counter, LBound(NewArray)) = _
arrFieldInfo(Counter)(LBound(arrFieldInfo))
NewArray(Counter, LBound(NewArray) + 1) = _
arrFieldInfo(Counter)(LBound(arrFieldInfo) + 1)
Next Counter


End Sub





--
Best regards
Leo Heuser

Followup to newsgroup only please.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default question about creating array

You're trying to import a file (say comma delimited) and want each field to be
text?

Dim myArray() As Variant
Dim iCtr As Long
Dim maxFields As Long

maxFields = 256 '256 columns maximum

ReDim myArray(1 To maxFields, 1 To 2)
For iCtr = 1 To maxFields
myArray(iCtr, 1) = iCtr
myArray(iCtr, 2) = 2
Next iCtr

Workbooks.OpenText Filename:="C:\someworkbookname.xls", Origin:=437, _
StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _
Comma:=False, _
Space:=False, Other:=False, FieldInfo:=myArray

wcc wrote:

Hello group,

What's a better way to create an array like this?

Dim arrFieldInfo As Variant
arrFieldInfo = Array(Array(1, 2),Array(2, 2),Array(3, 2),Array(4,
2),Array(5, 2),Array(6, 2),Array(7, 2),Array(8, 2),Array(9,
2),Array(10, 2),Array(11, 2),Array(12, 2),Array(13, 2),Array(14,
2),Array(15, 2),Array(16, 2),Array(17, 2), Array(18,2),Array(19,
2),Array(20, 2),Array(21, 2),Array(22, 2), Array(23, 2), Array(24,
2),Array(25, 2),Array(26, 2),Array(27, 2),Array(28, 2),
Array(29, 2),Array(30, 2),Array(31, 2),Array(32, 2))

Thans for your help.

wcc


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default question about creating array

Thanks a lot Dave. That is exactly what I'm trying to do. Also thanks
to Leo for helping.

A question on the argument "origin". What does 437 represent? From the
help file, I only see three values:
xlMacintosh 1
xlMSDOS 3
xlWindows 2

I'm using xlWindows. Just curious.

Regards,
wcc

Dave Peterson wrote:
You're trying to import a file (say comma delimited) and want each field to be
text?

Dim myArray() As Variant
Dim iCtr As Long
Dim maxFields As Long

maxFields = 256 '256 columns maximum

ReDim myArray(1 To maxFields, 1 To 2)
For iCtr = 1 To maxFields
myArray(iCtr, 1) = iCtr
myArray(iCtr, 2) = 2
Next iCtr

Workbooks.OpenText Filename:="C:\someworkbookname.xls", Origin:=437, _
StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _
Comma:=False, _
Space:=False, Other:=False, FieldInfo:=myArray

wcc wrote:

Hello group,

What's a better way to create an array like this?

Dim arrFieldInfo As Variant
arrFieldInfo = Array(Array(1, 2),Array(2, 2),Array(3, 2),Array(4,
2),Array(5, 2),Array(6, 2),Array(7, 2),Array(8, 2),Array(9,
2),Array(10, 2),Array(11, 2),Array(12, 2),Array(13, 2),Array(14,
2),Array(15, 2),Array(16, 2),Array(17, 2), Array(18,2),Array(19,
2),Array(20, 2),Array(21, 2),Array(22, 2), Array(23, 2), Array(24,
2),Array(25, 2),Array(26, 2),Array(27, 2),Array(28, 2),
Array(29, 2),Array(30, 2),Array(31, 2),Array(32, 2))

Thans for your help.

wcc


--

Dave Peterson


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default question about creating array

I should have deleted it!

From xl2003's help:

Additionally, this could be an integer representing the code page number of the
desired code page. For example, "1256" would specify that the encoding of the
source text file is Arabic (Windows). If this argument is omitted, the method
uses the current setting of the File Origin option in the Text Import Wizard.

I use USA Windows setting--so I'm guessing that it's got something to do with
that.

wcc wrote:

Thanks a lot Dave. That is exactly what I'm trying to do. Also thanks
to Leo for helping.

A question on the argument "origin". What does 437 represent? From the
help file, I only see three values:
xlMacintosh 1
xlMSDOS 3
xlWindows 2

I'm using xlWindows. Just curious.

Regards,
wcc

Dave Peterson wrote:
You're trying to import a file (say comma delimited) and want each field to be
text?

Dim myArray() As Variant
Dim iCtr As Long
Dim maxFields As Long

maxFields = 256 '256 columns maximum

ReDim myArray(1 To maxFields, 1 To 2)
For iCtr = 1 To maxFields
myArray(iCtr, 1) = iCtr
myArray(iCtr, 2) = 2
Next iCtr

Workbooks.OpenText Filename:="C:\someworkbookname.xls", Origin:=437, _
StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _
Comma:=False, _
Space:=False, Other:=False, FieldInfo:=myArray

wcc wrote:

Hello group,

What's a better way to create an array like this?

Dim arrFieldInfo As Variant
arrFieldInfo = Array(Array(1, 2),Array(2, 2),Array(3, 2),Array(4,
2),Array(5, 2),Array(6, 2),Array(7, 2),Array(8, 2),Array(9,
2),Array(10, 2),Array(11, 2),Array(12, 2),Array(13, 2),Array(14,
2),Array(15, 2),Array(16, 2),Array(17, 2), Array(18,2),Array(19,
2),Array(20, 2),Array(21, 2),Array(22, 2), Array(23, 2), Array(24,
2),Array(25, 2),Array(26, 2),Array(27, 2),Array(28, 2),
Array(29, 2),Array(30, 2),Array(31, 2),Array(32, 2))

Thans for your help.

wcc


--

Dave Peterson


--

Dave Peterson
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
Creating a list of value from an array Moanster Excel Worksheet Functions 2 June 20th 07 04:22 PM
creating an array Richard New Users to Excel 4 March 15th 07 01:06 PM
creating an array Richard Excel Worksheet Functions 4 March 15th 07 01:06 PM
Creating an Array Formula fdtoo[_2_] Excel Programming 2 August 2nd 05 08:35 AM
Creating an array Eric[_6_] Excel Programming 1 January 12th 04 08:25 PM


All times are GMT +1. The time now is 07:41 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"