Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default handling data in arrays? getting a bit knotted

Hi,

ok I admit I'm not much cop at this so a cry for help....

I've got some data in Excel and got it into an array.. great...
now I want to loop through each entry and check the data... if it
matches certain criteria I need to put it into a separate array which
I will then slap back onto a sheet. The data has four values for each
line eg

lonUK, sheffUK, summer, holiday
mancUK, leedUK, autumn, holiday
parisFR, DubIR, spring, work

so i want to loop through the data checking the first two values, of
each record, if they contain UK or IR as the last two letters I want
to extract them into a separate array which I can then paste onto a
separate worksheet area. thats it but it's sort of got me in a
muddle.

any help apprecited

Bobsa
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default handling data in arrays? getting a bit knotted

Sub Tester1()
Dim arr, arr2
Dim nRows As Long, nCols As Long
Dim i As Long, j As Long, k As Long
Dim l As Long
arr = Range("A1").CurrentRegion
ReDim arr2(LBound(arr, 2) To UBound(arr, 2), _
LBound(arr, 1) To UBound(arr, 1))
i = LBound(arr2, 2) - 1
For k = LBound(arr, 1) To UBound(arr, 1)
If InStr(arr(k, LBound(arr, 2)), "UK") Or _
InStr(arr(k, LBound(arr, 2) + 1), "UK") Or _
InStr(arr(k, LBound(arr, 2)), "IR") Or _
InStr(arr(k, LBound(arr, 2) + 1), "IR") _
Then
i = i + 1
For l = LBound(arr, 2) To UBound(arr, 2)
arr2(l, i) = arr(k, l)
Next
End If
Next
ReDim Preserve arr2(LBound(arr2, 1) To UBound(arr2, 1), _
LBound(arr, 1) To i)
nRows = UBound(arr2, 1) - LBound(arr2, 1) + 1
nCols = UBound(arr2, 2) - LBound(arr2, 2) + 1
Range("M2").Resize(nCols, nRows) = Application.Transpose(arr2)

End Sub

As written, picks up data around cell A1 and puts the results in column M
and to the right starting in cell M2.

--
Regards,
Tom Ogilvy




"Bobsa" wrote in message
om...
Hi,

ok I admit I'm not much cop at this so a cry for help....

I've got some data in Excel and got it into an array.. great...
now I want to loop through each entry and check the data... if it
matches certain criteria I need to put it into a separate array which
I will then slap back onto a sheet. The data has four values for each
line eg

lonUK, sheffUK, summer, holiday
mancUK, leedUK, autumn, holiday
parisFR, DubIR, spring, work

so i want to loop through the data checking the first two values, of
each record, if they contain UK or IR as the last two letters I want
to extract them into a separate array which I can then paste onto a
separate worksheet area. thats it but it's sort of got me in a
muddle.

any help apprecited

Bobsa



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
Handling blank data points jo2109 Charts and Charting in Excel 3 March 7th 09 09:01 AM
Series Lines Handling of Missing Data [email protected] Charts and Charting in Excel 1 December 8th 05 10:24 PM
Handling "Blank Entries" through Data Validation Jai Excel Discussion (Misc queries) 2 August 19th 05 04:21 PM
Mixed Data Handling easy Charts and Charting in Excel 2 March 16th 05 03:21 AM
OLE Excel data handling from VB Faiz[_2_] Excel Programming 2 July 11th 03 02:32 PM


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