Macro to delete specific rows in different worksheets
Tim, you might be chasing a shadow with the delete and shift method. Excel
only supports the shifting of an entire column or row, not partials.
However, you could use the cut and paste methods to move specific ranges. As
an example, if you find and empty cell and want to shift all data from right
to left.
'Establish right boundry
lastCol = Cells(Columns.Count, 1).End(xlToLeft).Column
'insert code to find empty cells and for first empty
EmptyCell = CellFound.Address
Range(Cells(0, Range(EmptyCell).Offset(0, 1).Col), Cells(0, lastCol).Cut
Range(EmptyCell)
This would have to be in a loop to execute for each emty cell found.
" wrote:
Hi All,
I've been looking around and have found plenty of examples of how to
delete rows of cells with blank entries, delete every nth row, etc,
but haven't found anything along the lines of what I'm wishing to do.
I have several worksheets, and I'm attempting to create a macro which
deletes (but doesn't delete the entire column, thus shifting every
other column left one..) a range in these worksheets.
I.e. I'm attempting to delete, in a worksheet "Data" every cell which
has an entry in it, in columns A and B - the reason for this, is that
I have a another column C which stores a formula working off the 2
cells in these columns, and is linked to a different worksheet which
will be the "end" product - i.e. presenting the calculated values.
Would anyone be able to point me in the right direction?
Cheers
Tim.
|