Question about looping

  • Thread starter Thread starter Brad
  • Start date Start date
B

Brad

What I want to do is to put the following two lines in a loop.

shtFixD.Rows("FixedFooter" & i).Delete
ActiveWorkbook.Names("FixedFooter" & i).Delete

Where I know the numbers start with 1 and increment by one. What I don't
know is how many "Footers" I have. How can I do this??
 
What is FixedFooter? What is i? I would normally expect a loop to identify a
key column, and identify the last row of that, and loop until the end of
that.
 
This should be close to what you want...

Sub DeleteStuff()
Dim nme As Name

For Each nme In ThisWorkbook.Names
With nme
If LCase(Left(.Name, 11)) = "fixedfooter" Then
.RefersToRange.EntireRow.Delete
.Delete
End If
End With
Next nme

End Sub
 
Thank you!!
--
Wag more, bark less


Jim Thomlinson said:
This should be close to what you want...

Sub DeleteStuff()
Dim nme As Name

For Each nme In ThisWorkbook.Names
With nme
If LCase(Left(.Name, 11)) = "fixedfooter" Then
.RefersToRange.EntireRow.Delete
.Delete
End If
End With
Next nme

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top