Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Handling blank data points | Charts and Charting in Excel | |||
Series Lines Handling of Missing Data | Charts and Charting in Excel | |||
Handling "Blank Entries" through Data Validation | Excel Discussion (Misc queries) | |||
Mixed Data Handling | Charts and Charting in Excel | |||
OLE Excel data handling from VB | Excel Programming |