ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   ClearContents does not work... (https://www.excelbanter.com/excel-programming/333288-clearcontents-does-not-work.html)

Kjartan

ClearContents does not work...
 
To make 'Empty' cells I expected this to work:

Worksheets("Sheet1").Range("F1:F15").ClearContents

.... but it does nothing... does not even clear numbers in those cells.
Do I need to use another method for this purpose ?


Thank's,
Kjartan



Liedson31

ClearContents does not work...
 
hi kjartan....
yes the code you have is ok....it works...
1 questions:
are you running this one in the workbook you want to "clearcontents"

if you donÂīt you have to put:
workbooks("workbookname").Worksheets("Sheet1").Ran ge("F1:F15").ClearContents

cheers
Miguel

"Kjartan" wrote:

To make 'Empty' cells I expected this to work:

Worksheets("Sheet1").Range("F1:F15").ClearContents

.... but it does nothing... does not even clear numbers in those cells.
Do I need to use another method for this purpose ?


Thank's,
Kjartan




Kjartan

ClearContents does not work...
 
Miguel,
Thank you for your reply.
My code is in a module. Adding the Workbookname did not work either...

"Liedson31" wrote in message
...
hi kjartan....
yes the code you have is ok....it works...
1 questions:
are you running this one in the workbook you want to "clearcontents"

if you donīt you have to put:
workbooks("workbookname").Worksheets("Sheet1").Ran ge("F1:F15").ClearContents

cheers
Miguel

"Kjartan" wrote:

To make 'Empty' cells I expected this to work:

Worksheets("Sheet1").Range("F1:F15").ClearContents

.... but it does nothing... does not even clear numbers in those cells.
Do I need to use another method for this purpose ?


Thank's,
Kjartan






Kjartan

ClearContents does not work...
 
I feel dum now :(... My code just needed to be inside the proper sheet... It
works fine now...

"Kjartan" wrote in message
...
Miguel,
Thank you for your reply.
My code is in a module. Adding the Workbookname did not work either...

"Liedson31" wrote in message
...
hi kjartan....
yes the code you have is ok....it works...
1 questions:
are you running this one in the workbook you want to "clearcontents"

if you donīt you have to put:
workbooks("workbookname").Worksheets("Sheet1").Ran ge("F1:F15").ClearContents

cheers
Miguel

"Kjartan" wrote:

To make 'Empty' cells I expected this to work:

Worksheets("Sheet1").Range("F1:F15").ClearContents

.... but it does nothing... does not even clear numbers in those cells.
Do I need to use another method for this purpose ?


Thank's,
Kjartan








K Dales[_2_]

ClearContents does not work...
 
You will need to show more of your code, then, to see what is happening. I
suspect your code never even hits this line. Is it inside a loop or an If
statement? Perhaps the conditions are not met to get the loop or the If
statement to run.

"Kjartan" wrote:

Miguel,
Thank you for your reply.
My code is in a module. Adding the Workbookname did not work either...

"Liedson31" wrote in message
...
hi kjartan....
yes the code you have is ok....it works...
1 questions:
are you running this one in the workbook you want to "clearcontents"

if you donÂīt you have to put:
workbooks("workbookname").Worksheets("Sheet1").Ran ge("F1:F15").ClearContents

cheers
Miguel

"Kjartan" wrote:

To make 'Empty' cells I expected this to work:

Worksheets("Sheet1").Range("F1:F15").ClearContents

.... but it does nothing... does not even clear numbers in those cells.
Do I need to use another method for this purpose ?


Thank's,
Kjartan







Tom Ogilvy

ClearContents does not work...
 
The original code worked fine for me and there is no reason is shouldn't
work. It is the correct syntax and the correct command. Test it by opening
only a single new workbook. then put some values in Sheet1!F1:F15. Now do
Alt+F11 and insert a new module.

Put in code like

Sub AAA()
Worksheets("Sheet1").Range("F1:F15").ClearContents
end Sub

Run the macro. It should work as you would expect.

--
Regards,
Tom Ogilvy

"Kjartan" wrote in message
...
Miguel,
Thank you for your reply.
My code is in a module. Adding the Workbookname did not work either...

"Liedson31" wrote in message
...
hi kjartan....
yes the code you have is ok....it works...
1 questions:
are you running this one in the workbook you want to "clearcontents"

if you donīt you have to put:

workbooks("workbookname").Worksheets("Sheet1").Ran ge("F1:F15").ClearContents

cheers
Miguel

"Kjartan" wrote:

To make 'Empty' cells I expected this to work:

Worksheets("Sheet1").Range("F1:F15").ClearContents

.... but it does nothing... does not even clear numbers in those cells.
Do I need to use another method for this purpose ?


Thank's,
Kjartan









All times are GMT +1. The time now is 11:52 PM.

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