ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Deleting columns/rows (https://www.excelbanter.com/excel-programming/400346-deleting-columns-rows.html)

dchristo

Deleting columns/rows
 
I want to clear a worksheet once the workbook opens; however, I don't want to
delete the header row and I don't want to delete/clears functions in column R
and S. How do I accomplish this?

Jim Thomlinson

Deleting columns/rows
 
This will clear A:Q and T:IV.
range(Cells(2, "A"), cells(rows.count, "Q")).ClearContents
range(Cells(2, "T"), cells(rows.count, columns.count)).ClearContents

Are there and constants in R:S that you want cleared? If so then add this ...
On Error Resume Next
Range("R2", Cells(Rows.Count,
"s")).SpecialCells(xlCellTypeConstants).ClearConte nts
On Error GoTo 0

**Note the above should be 3 lines but it will probably show up as 4 lines.
--
HTH...

Jim Thomlinson


"dchristo" wrote:

I want to clear a worksheet once the workbook opens; however, I don't want to
delete the header row and I don't want to delete/clears functions in column R
and S. How do I accomplish this?


dchristo

Deleting columns/rows
 
That was perfect, thank you for your help!!

"Jim Thomlinson" wrote:

This will clear A:Q and T:IV.
range(Cells(2, "A"), cells(rows.count, "Q")).ClearContents
range(Cells(2, "T"), cells(rows.count, columns.count)).ClearContents

Are there and constants in R:S that you want cleared? If so then add this ...
On Error Resume Next
Range("R2", Cells(Rows.Count,
"s")).SpecialCells(xlCellTypeConstants).ClearConte nts
On Error GoTo 0

**Note the above should be 3 lines but it will probably show up as 4 lines.
--
HTH...

Jim Thomlinson


"dchristo" wrote:

I want to clear a worksheet once the workbook opens; however, I don't want to
delete the header row and I don't want to delete/clears functions in column R
and S. How do I accomplish this?



All times are GMT +1. The time now is 08:43 AM.

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