Hi
below code not working as he suppose to...
when i run macro it delete entire column against range("A1:A5")
i want to delete column from 4 to 1 , Column B is my first column
i will appreciate any help on this
delete column
-
-
-
-
Re: delete column
Thanks 4 reply
i have mention my query in attach sheet,
purpose for keeping c as range because i want to delete columns with
certain criteria. -
Re: delete column
Hi Bill
i have resolve my query for my attachment, find below code.
but curious to know about my first posted codeCode
Display MoreSub nvgp() Dim rngFound As Range Dim sAddr As String, rw As Long Dim c As String Dim v, x As Variant c = Sheets("Main data").Range("A2").Value With Worksheets("Criteria") Set rngFound = .Cells.Find(What:=c, _ After:=ActiveCell, _ LookIn:=xlValues, _ LookAt:=xlPart, _ SearchOrder:=xlByRows, _ SearchDirection:=xlNext, _ MatchCase:=False) End With For i = 5 To 1 Step -1 v = Array((rngFound.Offset(0, i).Value)) With Worksheets("Main data") LastCol = Cells(1, Columns.Count).End(xlToLeft).Column For delcol = LastCol To 1 Step -1 bFound = False For x = LBound(v) To UBound(v) If InStr(1, Cells(1, delcol), v(x), vbTextCompare) And _ Len(Cells(1, delcol)) = Len(v(x)) Then bFound = True Exit For End If Next x If bFound Then _ Cells(1, delcol).EntireColumn.Delete Next delcol End With Next i End Sub
Never Give up
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!