Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Macro to clear cell data without clearing headings

I am trying to set up a macro to clear the data from all the cells on a
worksheet without clearing the column headings on the worksheet. How do I
accomplish this?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Macro to clear cell data without clearing headings

If your headers are in rows 1:12

with worksheets("sheet1")
.range("13:" & .rows.count).clearcontents
end with

But do you have stuff you have to keep in (say) column A?



DOOGIE wrote:

I am trying to set up a macro to clear the data from all the cells on a
worksheet without clearing the column headings on the worksheet. How do I
accomplish this?


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Macro to clear cell data without clearing headings

No. What I have is a worksheet that collects data for different time periods.
So each time it collects data, it may have a different number of rows of
data. What I want to do is to delete all of the collected data before I start
another data collection. I suppose that I could select all the cells from the
first row of data down to the bottom of the worksheet, but I was hoping to
avoid that.

"Dave Peterson" wrote:

If your headers are in rows 1:12

with worksheets("sheet1")
.range("13:" & .rows.count).clearcontents
end with

But do you have stuff you have to keep in (say) column A?



DOOGIE wrote:

I am trying to set up a macro to clear the data from all the cells on a
worksheet without clearing the column headings on the worksheet. How do I
accomplish this?


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Macro to clear cell data without clearing headings

Try selecting all the cells that need to be cleared (click and ctrl-click)
Then Insert|Name|Define
and give that selection a nice name

Then you can type that nice name in the Namebox (to the left of the formula bar)
to select that range.

Then hit the delete key.

If you have lots and lots of cells, then assigning the name this may fail.

You could try:
selecting the cells
hit alt-f8 to see the VBE
hit ctrl-g to see the immediate window

type this and hit enter:
selection.name = "MyList"

(myList is now the name of that selection. Use the name you want.)

And back to excel.
select a cell
and then test it out using the namebox.

DOOGIE wrote:

No. What I have is a worksheet that collects data for different time periods.
So each time it collects data, it may have a different number of rows of
data. What I want to do is to delete all of the collected data before I start
another data collection. I suppose that I could select all the cells from the
first row of data down to the bottom of the worksheet, but I was hoping to
avoid that.

"Dave Peterson" wrote:

If your headers are in rows 1:12

with worksheets("sheet1")
.range("13:" & .rows.count).clearcontents
end with

But do you have stuff you have to keep in (say) column A?



DOOGIE wrote:

I am trying to set up a macro to clear the data from all the cells on a
worksheet without clearing the column headings on the worksheet. How do I
accomplish this?


--

Dave Peterson


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Clear a worksheet without clearing formulas? doodah Excel Discussion (Misc queries) 5 January 23rd 07 06:45 PM
How do I clear a column of data without clearing specific cells? EllenSwarts Excel Discussion (Misc queries) 2 April 5th 06 05:07 PM
Excel should let me clear cell contents without clearing formulas BJM Excel Programming 5 November 19th 05 04:52 PM
How do I clear a column of data without clearing the formulas? EllenSwarts Excel Discussion (Misc queries) 2 March 11th 05 02:09 PM
Macro - Cell clearing Paul H Excel Programming 11 January 7th 05 05:30 PM


All times are GMT +1. The time now is 04:52 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"