ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Clear contents (https://www.excelbanter.com/excel-programming/364339-clear-contents.html)

SamanthaK

Clear contents
 
I am writing macro that clears the contents of a spreadsheet. After this is
done the whole spreadsheet is selected (it is blue...). How do I write code
so that the spreadsheet is not selected after clear contents is done?
--
I am very thankful for any fast assistance!

Norman Jones

Clear contents
 
Hi Samantha,

Try removing selections from your code.

If this is a problem for you, post your code.


---
Regards,
Norman



"SamanthaK" wrote in message
...
I am writing macro that clears the contents of a spreadsheet. After this is
done the whole spreadsheet is selected (it is blue...). How do I write
code
so that the spreadsheet is not selected after clear contents is done?
--
I am very thankful for any fast assistance!




[email protected]

Clear contents
 
You haven't quoted any of your code, but I'm guessing you've got a
range.select or cells.select in there somewhere so that your code is
something like

Cells.Select
Selection.ClearContents


(which is exactly what you would get if you recorded the macro)

try

Cells.ClearContents

I think you will find this fixes it!



SamanthaK wrote:
I am writing macro that clears the contents of a spreadsheet. After this is
done the whole spreadsheet is selected (it is blue...). How do I write code
so that the spreadsheet is not selected after clear contents is done?
--
I am very thankful for any fast assistance!



FSt1

Clear contents
 
hi,
add this line to your code after the clear contents.
Range("A1").select 'or select another cell
or
Cells(1,1).select

regards
FSt1

"SamanthaK" wrote:

I am writing macro that clears the contents of a spreadsheet. After this is
done the whole spreadsheet is selected (it is blue...). How do I write code
so that the spreadsheet is not selected after clear contents is done?
--
I am very thankful for any fast assistance!



All times are GMT +1. The time now is 05:37 AM.

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