Loop until meet requirement

keevans

Board Regular
Joined
Aug 22, 2013
Messages
77
I want to call a procedure "DeleteSignature" until a condition is met. My condition would be Range("A45").Value="Contact". How do I set up the loop? Is a loop the right thing to use? Sorry VBA newbie here. Your help is appreciated!
 

Some videos you may like

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Momentman

Well-known Member
Joined
Jan 11, 2012
Messages
4,037
Office Version
  1. 365
Platform
  1. Windows
Ideally you would be doing something like a "Do-----Loop until range("A45").value...." but what exactly are you looping through(rows, columns,range...) and what does the deletesignature do?
 

keevans

Board Regular
Joined
Aug 22, 2013
Messages
77
Thanks! That's kind of what I was thinking, I just don't know how to write it. :S My delete signature is copied below.

Code:
Sub DeleteSignatures()
Range(Rows(46), Rows(46 + 5)).Select
Selection.Delete Shift:=xlUp
End Sub
 

Momentman

Well-known Member
Joined
Jan 11, 2012
Messages
4,037
Office Version
  1. 365
Platform
  1. Windows
Looking at the situation, do you really need a Loop? I think not

What of having it this way?
Code:
Sub DeleteSignatures()
    If Range("A45").Value <> "Contact" Then
        Range(Rows(46), Rows(46 + 5)).Select
        Selection.Delete Shift:=xlUp
    End If
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,109,045
Messages
5,526,447
Members
409,701
Latest member
nitmani

This Week's Hot Topics

Top