Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Clearing data from Excel 2003 Form

Hi, I have an Excel Form with cells for direct data entry and cells with
formulas. The form is protected so that only those cells for direct data
entry are editable. All the other cells are locked. I want to create a macro
to clear all the data from the unlocked cells. I recorded a macro using the
F5 (goto) function key, the shift key to select contiguous cells, and the
delete key to clear those cells. The problem is, if I move anything on the
form, the cell references in the macro don't change. I have to edit the macro
in the vb editor.

Is there a way to select, in a protected sheet, all unlocked cells and
delete their contents, without using cell references that may change when the
form is changed?

Any help is greatly appreciated,
Bernie
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Clearing data from Excel 2003 Form


If the cells are for direct entry it's unlikely they'll have a formula
in so:

Range("E9:H33").SpecialCells(xlCellTypeConstants,
7).ClearContents

otherwise to detect unlocked cells:

For Each cll In Range("E9:H33").Cells
If Not cll.Locked Then cll.ClearContents
Next cll


--
p45cal

*p45cal*
------------------------------------------------------------------------
p45cal's Profile: http://www.thecodecage.com/forumz/member.php?userid=558
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=120852

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Clearing data from Excel 2003 Form

Thank you for the response. Unfortunately, the first code doesn't work on
protected sheets. The second code started to work but stopped when it hit a
merged cell. I get "Run time error '1004': Cannot change part of a merged
cell." Do you know of a way around that?
Thanks again, Bernie

"p45cal" wrote:


If the cells are for direct entry it's unlikely they'll have a formula
in so:

Range("E9:H33").SpecialCells(xlCellTypeConstants,
7).ClearContents

otherwise to detect unlocked cells:

For Each cll In Range("E9:H33").Cells
If Not cll.Locked Then cll.ClearContents
Next cll


--
p45cal

*p45cal*
------------------------------------------------------------------------
p45cal's Profile: http://www.thecodecage.com/forumz/member.php?userid=558
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=120852


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Clearing data from Excel 2003 Form


First code, use:
Activesheet.protect UserInterfaceOnly:=true
to protect the sheet.

Second code, don't use merged cells! Are you wanting to clear data from
merged cells? or are these cells headers?
If the merged cells are cells from the same row then use -Centre across
selection- in the -Horizontal -section of the -Text Alignment- section
of the -Alignment -tab of the -Format Cells- dialogue box *instead* of
merging them.

berniean;436168 Wrote:
Thank you for the response. Unfortunately, the first code doesn't work
on
protected sheets. The second code started to work but stopped when it
hit a
merged cell. I get "Run time error '1004': Cannot change part of a
merged
cell." Do you know of a way around that?
Thanks again, Bernie



--
p45cal

*p45cal*
------------------------------------------------------------------------
p45cal's Profile: http://www.thecodecage.com/forumz/member.php?userid=558
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=120852

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
Drop-down list on simple excel 2003 form using "form" from data me S Beals Excel Discussion (Misc queries) 0 March 2nd 10 08:35 PM
Excel 2003 - Customise a Data Form for dropdown lists JohnLBS Excel Discussion (Misc queries) 1 May 3rd 07 11:55 AM
How do I save worksheet form data into a table in Excel 2003? Bob S. Excel Discussion (Misc queries) 0 December 31st 05 04:33 PM
create a data entry form template in Excel 2003? david.bottomley@haltoncollege Excel Discussion (Misc queries) 0 January 19th 05 09:59 AM
Clearing Form PEno1 Excel Programming 2 December 12th 04 09:18 PM


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

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"