PDA

View Full Version : Solved: listing errors in data, using Vlookup



divingdingo
11-20-2007, 09:58 AM
hi guys, i'm back again!!

my problem this time is that occasionally my large arrays of wind data arrives with some dates missing corresponding data. i would like to identify these dates in a table on a seperate sheet, and i think i need to use Vlookup although i'm not positive about how i should!

my data comes in two columns;

date, windspeed.

occassionaly wind speed = 0 (this means there has been no recording taken)

i would like VBA to search through my windspeed column until it finds a 0, then copy the date on a serperate sheet("missing_dates") after that continue on to the next occasion when 0 is encountered and copy the date underneath the last entry.

thanks for any help received.

mark

ProteanBeing
11-20-2007, 10:09 AM
This may work for you.

counter = first_data_row
collected = 1 ' counts the number of 0s collected
do while worksheets(wind_data).cells(counter, windspeed_col) <> ""
if worksheets(wind_data).cells(counter, windspeed_col)=0 then
worksheets("missing_dates").cells(collected, 1) = worksheets(wind_data).cells(counter, windspeed_col
collected = collected+1
end if
counter = counter +1
loop

Bob Phillips
11-20-2007, 12:07 PM
Sub ProcessData()
Dim LastRow As Long
Dim rng As Range
Dim sh As Worksheet

With Worksheets("data example")

LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

Set rng = .Range("A1").Resize(LastRow, 2)
rng.AutoFilter Field:=2, Criteria1:=0
Set rng = .Range("A2").Resize(LastRow - 1, 2).SpecialCells(xlCellTypeVisible)
Set sh = Worksheets.Add
sh.Name = "zero data"
rng.Copy sh.Range("A1")
End With
End Sub

divingdingo
11-21-2007, 06:44 AM
thank you xld.

it worked perfectly.

iadded some code that then counted the missing records and then displays that as a % of the original no. of records.

i'm so pleased with myself!!

thanks again. and more likely another problem coming soon....