Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,814
Default clear data from selected cells

Hello, I have a excel tempate for compiling data. How do I add a Control
button to clear data in unprotected cells only? Can you help? Steve
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default clear data from selected cells

I assume you are looking of code and not how to add a button to a sheet

for each cell in Activesheet.UsedRange
if cell.Locked = False then
cell.ClearContents
end if
Next

--
Regards,
Tom Ogilvy


"Steve" wrote in message
...
Hello, I have a excel tempate for compiling data. How do I add a Control
button to clear data in unprotected cells only? Can you help? Steve



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,814
Default clear data from selected cells

Hi Tom,
Yes, I already have a macro and button. I added protected cells to range, I
can't seem to edit the macro without errors. Current macros:
Sub clear()
'
' clear Macro
' Macro recorded 1/15/2006 by steve smith
'

'
Range("B2:G10").Select
Range("B2").Activate
Selection.ClearContents
End Sub

I am fairly new to VB. Thank You, Steve

"Tom Ogilvy" wrote:

I assume you are looking of code and not how to add a button to a sheet

for each cell in Activesheet.UsedRange
if cell.Locked = False then
cell.ClearContents
end if
Next

--
Regards,
Tom Ogilvy


"Steve" wrote in message
...
Hello, I have a excel tempate for compiling data. How do I add a Control
button to clear data in unprotected cells only? Can you help? Steve




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default clear data from selected cells

Sub clear()
'
' clear Macro
' Macro recorded 1/15/2006 by steve smith
'

'
Dim cell as Range
Range("B2:G10").Select
Range("B2").Activate
for each cell in selection
if cell.locked = false then
cell.ClearContents
end if
Next
End Sub

should work I would think.

--
Regards,
Tom Ogilvy

"Steve" wrote in message
...
Hi Tom,
Yes, I already have a macro and button. I added protected cells to range,

I
can't seem to edit the macro without errors. Current macros:
Sub clear()
'
' clear Macro
' Macro recorded 1/15/2006 by steve smith
'

'
Range("B2:G10").Select
Range("B2").Activate
Selection.ClearContents
End Sub

I am fairly new to VB. Thank You, Steve

"Tom Ogilvy" wrote:

I assume you are looking of code and not how to add a button to a sheet

for each cell in Activesheet.UsedRange
if cell.Locked = False then
cell.ClearContents
end if
Next

--
Regards,
Tom Ogilvy


"Steve" wrote in message
...
Hello, I have a excel tempate for compiling data. How do I add a

Control
button to clear data in unprotected cells only? Can you help? Steve






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
How to clear multiple cells of input data in Excel simultaneously sstea Excel Worksheet Functions 12 May 2nd 09 08:47 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
Can I lock data into few cells in sheet and clear the rest eabrown Excel Discussion (Misc queries) 1 February 15th 06 05:41 PM
Automatically clear values from a range of selected cells John Davies Excel Discussion (Misc queries) 1 June 28th 05 04:42 PM
How do I clear data in selected cells automatically Jim Train Excel Discussion (Misc queries) 1 May 25th 05 06:45 PM


All times are GMT +1. The time now is 01:41 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"