Thread: simple macro?
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JLGWhiz[_2_] JLGWhiz[_2_] is offline
external usenet poster
 
Posts: 1,565
Default simple macro?


This does what you described, but I need to point out that it is based on
the assumption that each customer record consists of two lines of data and
that you only want to delete the first line if it meet the conditions that
you described. If that is not what you want, then re-define your problem
and re-post.

Also, this works from the bottom up, which prevents skipping any consecutive
bland rows.

Sub chkforblank()
Dim lr As Long, i As Long, sh As Worksheet
Set sh = ActiveSheet
lr = sh.Cells(Rows.Count, 1).End(xlUp).Row
If lr Mod 2 = 0 Then
For i = lr To 1 Step -2
If sh.Cells(i - 1, 2) = "" And _
sh.Cells(i, 1) < "X" Then
Rows(i - 1).Delete
End If
Next
End If
End Sub



"MusicMan" wrote in message
...
I need a macro that will from A1 test if B1 is blank and if A2<"X" delete
row A1, else move down and repeat.

I have a col of customer info in Col B which ahs extra blank rows within.
An "X" in Col A denotes a new customer so the last line of a customer info
should be blank hence the test above for A2

I was a wizz at Lotus macros but new to Excel VBA.