LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default Populating a multi dimensional array

Hi,
Thanks for responses. I'm still a bit stuck. I've changed my array to a
122x2 array for ease, but I'm still having problems with passing values into
the array. I get a type mismatch error, so I guess I haven't declared my
properties correctly but just can't work it out.

The data is being collected from a sheet, that has data randomly entered
across 18 columns, I need to pick up the value from Column A, row x, check
columns 1-18 for value set to 1, then lookup the column heading and take that
value, with both these values I need to populate the array, then move on to
the next row and repeat.

Thanks

Wendy
==============
Option Base 1

Sub Enrol_Scrape()
Dim x As Integer
Dim col As Integer
Dim row As Integer
Dim rng As Range
Dim PCode, Subject As Variant
Dim MyArray() As Variant

Numrows = Range("CStudent", Range("CStudent").End(xlDown)).Rows.Count
Range("A4").Select
For x = 0 To Numrows
ActiveCell.Offset(x, 0).Activate
PCode = ActiveCell.Value
For col = 0 To 18

If ActiveCell.Offset(x, col).Value = 1 Then
MsgBox (ActiveCell.Offset(x, col).Address)
row = ActiveCell.row - 2
Subject = ActiveCell.Offset(-row, col).Text
End If
Next col
For i = 1 To 122
ReDim Preserve MyArray(i, 2)
x = x + 1
MyArray(i) = Array(PCode(i, 1), Subject(i, 2))
Next i
Next x ' move to next row


'Sheets("PASS").Activate
'Range("A2:C2").Activate
'Range("A2:C2").Value = MyArray
End Sub
==================================

" wrote:

This might help. Note the sweet ending which allows you to insert the
array into another worksheet in a single VBA statement.

Sub move()

Dim arr() As Variant
Dim i As Long
Dim b As Workbook
Dim s1 As Worksheet
Dim s2 As Worksheet
Set b = ThisWorkbook
Set s1 = b.Sheets("Sheet1")
Set s2 = b.Sheets("Sheet2")
For i = 1 To 122
ReDim Preserve arr(1 To i)
arr(i) = Array(s1.Cells(i, 1), s1.Cells(i, 2), s1.Cells(i, 3))
Next
s2.Range("A1:C122").Value =
Application.Transpose(Application.Transpose(arr))
End Sub



 
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
Multi Dimensional Array steve Excel Programming 4 September 26th 06 07:33 PM
Multi Dimensional Array andym Excel Programming 11 July 10th 06 05:09 AM
Populating Two Dimensional Array willz99ta via OfficeKB.com Excel Programming 6 March 15th 06 03:22 PM
Multi-Dimensional Array Let & Get Trip[_3_] Excel Programming 0 September 21st 05 08:41 PM
Viewing Multi dimensional array Codea[_2_] Excel Programming 0 August 5th 04 12:49 PM


All times are GMT +1. The time now is 02:55 PM.

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"