View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default Filtering daily data

Tim,

Did you try this variant, when there wasn't a 1 to be found?

Set myCell = Range("A:A").Find(Application.Min(Range("A:A")), , , xlWhole)

Otherwise, you need to check after the find:

'Find the 1
Set myCell = Range("A:H").Find(1, , , xlWhole)

'If a 1 is found, myCell is a range
'If it isn't found, it is Nothing
If Not myCell Is Nothing Then
Range(myCell, "A65536").Resize(, 8).Delete Shift:=xlUp
End If

HTH,
Bernie
MS Excel MVP


wrote in message
oups.com...
Bernie,

Thank you for all your help on this. I ended going with a delete,
where you delete the selected range and shift the cells up:

Set myCell = Range("A:H").Find(1, , , xlWhole)
Range(myCell, "A65536").Resize(, 8).Delete Shift:=xlUp

I have another problem that just manifested itself today.

The problem is that the logs are generated every day, whether there is
production or not. So, when I ran the report today for Friday and
Saturday, there was no "1" in Saturday's log to key off of. This
caused an error and the macro halted. The error is "Run-time error
'1004': Method 'Range' of object '_Global' failed. The line that it
wants me to debug is:

Range(myCell, "A65536").Resize(, 8).Delete Shift:=xlUp

I am assuming that I get the error because myCell has no value because
there wasn't a "1" to find in the previous line of code (see above
posts).

Is there a way to integrate some error handling for this?

Tim