ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Leave last col alone (https://www.excelbanter.com/excel-programming/275821-re-leave-last-col-alone.html)

David Turner

Leave last col alone
 
Greg Wilson wrote

Range(Cells(c.Row, 1), Cells(c.Row, 255)).ClearContents


Actually, this syntax allowed me to successfully handle another workbook
where I had to clear multiple ranges in the same row:

cols = ActiveSheet.UsedRange.Columns.Count
Set rng = Range(Cells(5, 1), Cells(Rows.Count, 1).End(xlUp).Offset(-6, 0))
For Each c In rng
If c = Old_Member Then
Range(Cells(c.Row, 1), Cells(c.Row, 2)).ClearContents
Range(Cells(c.Row, 10), Cells(c.Row, cols)).ClearContents
End If
Next c

Many thanks!

--
David


All times are GMT +1. The time now is 02:28 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com