View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett[_2_] Don Guillett[_2_] is offline
external usenet poster
 
Posts: 1,522
Default Deleting Columns with VBA


Sub delcolbandcif()
If Application.Match(2, Rows(1), 1) - _
Application.Match(2, Rows(1), 0) 1 Then _
Columns("b:c").Delete
End Sub

On Oct 18, 1:21*pm, "kittronald" wrote:
* * I'm trying to programmatically delete columns based on a criteria..

* * If A1=1 and B1=2, do nothing.

* * If A1=1, B1<2, C1<2 and D1=2, delete columns B:C.

* * I could test with the following:

* * * * If Application.Match(1, Range("Sheet1!$1:$1"), 0) -
Application.Match(2, Range("Sheet1!$1:$1"), 0) 1 Then

* * But I don't see how to form:

* * * * *.Columns("B:C").Delete

- Ronald K.