• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Delete row failure

Chris L

New Member
I have a large worksheet that the first column is time HH:MM:SS in 30 second increments.
I sort through all this and return 4 hours worth of data at a 15 minute interval and a final row.
The following was given to me when I wanted to look at the last two rows and if only the seconds were different delete row 18

>>> use code - tags <<<
Code:
  Rows("18:19").Select
    With [A1].CurrentRegion.Rows
        If Left(.Cells(.Count - 1, 1).Text, 5) = Left(.Cells(.Count, 1).Text, 5) Then .Item(.Count - 1).Delete
    End With
Right now if both rows are empty I get a debugging error and have to manually jump past this code.
Can I add something to ignore this if cells are empty?
 
Last edited by a moderator:
I've been trying to reproduce your error, so far I can get it if there's nothing in cell A1 or only one row of data (I haven't been exhaustive in looking for this). Could you put together a very simple spreadsheet with just the necessary to make this error occur and attach it here?
 
Right now if both rows are empty
As there is no empty row with CurrentRegion statement,​
if there is no more than one row then you must check at least if exist several rows.​
By the way the Select codeline is totally useless, was not within the original code !​
 
If my process runs as planned there is no problem.
The problem exists if there is no data to compare, the sheet this is running on is empty and I just want to jump past this and continue with the macro.
I can generate some dummy data and send later, actual data is ITAR restricted.
 
Code:
With [A1].CurrentRegion.Rows
  If .Count > 1 Then
    If Left(.Cells(.Count - 1, 1).Text, 5) = Left(.Cells(.Count, 1).Text, 5) Then .Item(.Count - 1).Delete
  End If
End With
?
 
Thank you, that works.

One more...

On Sheet1 in S1 is a time stamp for the beginning of an event T1 is the end.
Sheet2 is all my data in rows with column A Time.
I want to Bold the two rows in Sheet2 based on the time values from Sheet1 S1 & T1
 
Back
Top