ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Clearing cells (https://www.excelbanter.com/excel-programming/349522-clearing-cells.html)

[email protected]

Clearing cells
 
I have the following code to clear columns at a specific cell number
and then all the way down the column, but I get a "invalid or
unqualified reference" error. Why is that? It stops on the .Cells
portion.....

Help?

Sheets("Generator").Select
.Range("b14:b" & .Cells(Rows.Count, "B").End(xlUp).Row).ClearContents
.Range("c14:c" & .Cells(Rows.Count, "C").End(xlUp).Row).ClearContents
.Range("d14:d" & .Cells(Rows.Count, "D").End(xlUp).Row).ClearContents
.Range("e14:e" & .Cells(Rows.Count, "E").End(xlUp).Row).ClearContents
.Range("f14:f" & .Cells(Rows.Count, "F").End(xlUp).Row).ClearContents
.Range("g14:g" & .Cells(Rows.Count, "G").End(xlUp).Row).ClearContents
.Range("i14:i" & .Cells(Rows.Count, "I").End(xlUp).Row).ClearContents


PCLIVE

Clearing cells
 
I'm not sure you need the periods before "Range" and "Cells".

Try this:

Sheets("Generator").Select
Range("b14:b" & Cells(Rows.Count, "B").End(xlUp).Row).ClearContents
Range("c14:c" & Cells(Rows.Count, "C").End(xlUp).Row).ClearContents
Range("d14:d" & Cells(Rows.Count, "D").End(xlUp).Row).ClearContents
Range("e14:e" & Cells(Rows.Count, "E").End(xlUp).Row).ClearContents
Range("f14:f" & Cells(Rows.Count, "F").End(xlUp).Row).ClearContents
Range("g14:g" & Cells(Rows.Count, "G").End(xlUp).Row).ClearContents
Range("i14:i" & Cells(Rows.Count, "I").End(xlUp).Row).ClearContents


wrote in message
ups.com...
I have the following code to clear columns at a specific cell number
and then all the way down the column, but I get a "invalid or
unqualified reference" error. Why is that? It stops on the .Cells
portion.....

Help?

Sheets("Generator").Select
.Range("b14:b" & .Cells(Rows.Count, "B").End(xlUp).Row).ClearContents
.Range("c14:c" & .Cells(Rows.Count, "C").End(xlUp).Row).ClearContents
.Range("d14:d" & .Cells(Rows.Count, "D").End(xlUp).Row).ClearContents
.Range("e14:e" & .Cells(Rows.Count, "E").End(xlUp).Row).ClearContents
.Range("f14:f" & .Cells(Rows.Count, "F").End(xlUp).Row).ClearContents
.Range("g14:g" & .Cells(Rows.Count, "G").End(xlUp).Row).ClearContents
.Range("i14:i" & .Cells(Rows.Count, "I").End(xlUp).Row).ClearContents





All times are GMT +1. The time now is 01:07 PM.

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