Home |
Search |
Today's Posts |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dave,
Your explanation makes perfect sense and solution works great. thanks ! "Dave Peterson" wrote: When you delete rows, it's easier to start at the bottom and work your way to the top. When you delete columns, it's easier to start at the far right and work your way to the left. Dim iCol As long dim LastCol as long with worksheets("Sheetnamehere") lastcol = .cells(1,.columns.count).end(xltoleft).column for icol = lastcol to 1 step -1 select case lcase(.cells(1,icol).value) case is = "doc. date", "type", "reference", "lc amnt" 'skip it case else .columns(icol).delete end select next icol end with Sometimes "select case" makes it a bit easier to see what's going on. SteveT wrote: Hello, I'm using JLGWhiz's solution in posting "Deleting Column Based On Header" to delete columns other than those correctly titled. - Below - It works Fine but only when run several times or repeated. Can someone help me enhance to automatically loop until either desired # of columns with data or until Column Headers indicated below all that left ? Dim C As Range lc = Cells(1, Columns.Count).End(xlToLeft).Column Set myRng = Range("A1", Cells(1, lc)) For Each C In myRng If C < "Doc. Date" And C < "DocumentN" And C < "Type" And C < "Reference" And C < "LC amnt" Then C.EntireColumn.Delete End If Next Many Thanks / Happy Holidays Steven all left -- Dave Peterson |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
In Excel My Columns are going from right to left, how can I fix i. | Excel Discussion (Misc queries) | |||
If < equal to named list require user to fill out desired columns? | Excel Programming | |||
Count number of times two columns have desired values | Excel Discussion (Misc queries) | |||
My columns run from right to left instead of left to right. Help? | Setting up and Configuration of Excel | |||
filtering columns-left nav | Charts and Charting in Excel |