View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Clean big arrays of data.... HELP !!

Hi Pierre,

Your requirements are not clear but here is my best guess.

Presumably you have (at least) thee populated columns: Date/Price/StockName.

Assume :
(1)Your data is on Sheet1 with your dates in columnA
(2)Your holiday dates are listed on Sheet2 in column A with a header in
cell A1
(2)You wish to delete all data rows where the date corresponds to a holiday
date.

If these assumptions work for you, then (on a copy workbook!) try:

Dim rng As Range, rng1 As Range
Dim myDate As Date
Dim res As Variant
Dim i As Long
Dim RngDel As Range
Dim RngHoliday As Range
Dim LCell As Range

With ActiveWorkbook.Sheets("Sheet2")
Set LCell = .Cells(Cells.Rows.Count, "A").End(xlUp)
Set RngHoliday = Range(.Cells(2, 1), LCell)
End With
For i = 1 To RngHoliday.Cells.Count
myDate = RngHoliday(i).Value
With Worksheets("Sheet1")
Set rng1 = .Range(.Cells(1, 1), _
.Cells(Cells.Rows.Count, "A").End(xlUp))
End With

res = Application.Match(CLng(myDate), rng1, 0)

Do While Not IsError(res)
On Error Resume Next
rng1(res).EntireRow.Delete
On Error GoTo 0
res = Application.Match(CLng(myDate), rng1, 0)
Loop
Next i

End Sub

---
Regards,
Norman

"Pierre " wrote in message
...
Hi all,

Let's say I have daily historical data (each has 2 col : date/price).
from 50 stocks on the past 3 years.
How can I "clean" this huge array to keep only the dates that are in
common (meaning, by removing the holidays specific to a country for
exemple).
I am a little bit stuck because doing a basic double loop is far to
long

Tx a lot


---
Message posted from http://www.ExcelForum.com/