Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
delete column sets current cell wrong
I have code that looks at the column headers in a sheet and in some
cases, deletes the column, in others, replaces the header with a different one, based on a table of old header values and new header values in a different workbook. The problem is, that as the macro goes through the range (rTtl), when a column is deleted, it skips the column to the deleted columns right and continues. In other words, rCell is one cell to the right of where I want it to be after a column is deleted. How do I "back up" rCell one cell to the left, the next unevaluated column, after a column is deleted? For Each rCell In rTtl strOldHd = rCell.Value Set rFoundHdr = rOldHds.Find(strOldHd, LookIn:=xlValues, LookAt:=xlWhole) If Not rFoundHdr Is Nothing Then If rFoundHdr.Offset(0, 2).Value = "delete" Then rCell.EntireColumn.Delete Set rCell = rCell.Offset(0, -1) <-----OBJECT REQUIRED error Else rCell.Value = rFoundHdr.Offset(0, 1).Value End If Else lHdrNotFoundCt = lHdrNotFoundCt + 1 End If Next rCell I tried to set it back using an offset, but that doesn't work, I just get an "Object Required" error on that line. Thanks for the help. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel graph 3 sets of data. 2 sets as lines 1 as column? | Charts and Charting in Excel | |||
Formating pre-sets are all wrong | Excel Discussion (Misc queries) | |||
Inesert value of column B of the current row into active cell | Excel Programming | |||
Can I get current #row or #column in cell formula? | Excel Discussion (Misc queries) | |||
How do I delete both sets of duplicate data? | Excel Discussion (Misc queries) |