#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 37
Default Delete cell contents

Could someone please provide some VBA code that will delete all cell
contents for all the unlocked cells in a sheet?

Rob


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Delete cell contents

Sub rob()
For Each r In ActiveSheet.UsedRange
If r.Locked Then
Else
r.ClearContents
End If
Next
End Sub
--
Gary''s Student - gsnu200713


"Rob" wrote:

Could someone please provide some VBA code that will delete all cell
contents for all the unlocked cells in a sheet?

Rob



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 37
Default Delete cell contents

Thankyou so much. Worked perfectly.

As an alternative for another application I have, could you also provide me
with the code to have cells only cleared from a specified range instead of
the whole sheet?

Rob

"Gary''s Student" wrote in message
...
Sub rob()
For Each r In ActiveSheet.UsedRange
If r.Locked Then
Else
r.ClearContents
End If
Next
End Sub
--
Gary''s Student - gsnu200713


"Rob" wrote:

Could someone please provide some VBA code that will delete all cell
contents for all the unlocked cells in a sheet?

Rob





  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Delete cell contents

Sub rob()
For Each r In Selection
If r.Locked Then
Else
r.ClearContents
End If
Next
End Sub

In this version, just Select the area you wish to clear before running the
macro.
--
Gary''s Student - gsnu200714


"Rob" wrote:

Thankyou so much. Worked perfectly.

As an alternative for another application I have, could you also provide me
with the code to have cells only cleared from a specified range instead of
the whole sheet?

Rob

"Gary''s Student" wrote in message
...
Sub rob()
For Each r In ActiveSheet.UsedRange
If r.Locked Then
Else
r.ClearContents
End If
Next
End Sub
--
Gary''s Student - gsnu200713


"Rob" wrote:

Could someone please provide some VBA code that will delete all cell
contents for all the unlocked cells in a sheet?

Rob






  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 37
Default Delete cell contents

Thanks again and that is useful, but could you please provide code that will
do a predefined range, such as A5:G200

Rob

"Gary''s Student" wrote in message
...
Sub rob()
For Each r In Selection
If r.Locked Then
Else
r.ClearContents
End If
Next
End Sub

In this version, just Select the area you wish to clear before running the
macro.
--
Gary''s Student - gsnu200714


"Rob" wrote:

Thankyou so much. Worked perfectly.

As an alternative for another application I have, could you also provide
me
with the code to have cells only cleared from a specified range instead
of
the whole sheet?

Rob

"Gary''s Student" wrote in
message
...
Sub rob()
For Each r In ActiveSheet.UsedRange
If r.Locked Then
Else
r.ClearContents
End If
Next
End Sub
--
Gary''s Student - gsnu200713


"Rob" wrote:

Could someone please provide some VBA code that will delete all cell
contents for all the unlocked cells in a sheet?

Rob










  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 37
Default Delete cell contents

And....
the condition that only the unlocked cells be cleared in the predefined
range still need to apply.

Rob

"Gary''s Student" wrote in message
...
Sub rob()
For Each r In Selection
If r.Locked Then
Else
r.ClearContents
End If
Next
End Sub

In this version, just Select the area you wish to clear before running the
macro.
--
Gary''s Student - gsnu200714


"Rob" wrote:

Thankyou so much. Worked perfectly.

As an alternative for another application I have, could you also provide
me
with the code to have cells only cleared from a specified range instead
of
the whole sheet?

Rob

"Gary''s Student" wrote in
message
...
Sub rob()
For Each r In ActiveSheet.UsedRange
If r.Locked Then
Else
r.ClearContents
End If
Next
End Sub
--
Gary''s Student - gsnu200713


"Rob" wrote:

Could someone please provide some VBA code that will delete all cell
contents for all the unlocked cells in a sheet?

Rob








  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Delete cell contents

Change this:
For Each r In Selection
to
For Each r In activesheet.range("a5:g200").cells



Rob wrote:

Thanks again and that is useful, but could you please provide code that will
do a predefined range, such as A5:G200

Rob

"Gary''s Student" wrote in message
...
Sub rob()
For Each r In Selection
If r.Locked Then
Else
r.ClearContents
End If
Next
End Sub

In this version, just Select the area you wish to clear before running the
macro.
--
Gary''s Student - gsnu200714


"Rob" wrote:

Thankyou so much. Worked perfectly.

As an alternative for another application I have, could you also provide
me
with the code to have cells only cleared from a specified range instead
of
the whole sheet?

Rob

"Gary''s Student" wrote in
message
...
Sub rob()
For Each r In ActiveSheet.UsedRange
If r.Locked Then
Else
r.ClearContents
End If
Next
End Sub
--
Gary''s Student - gsnu200713


"Rob" wrote:

Could someone please provide some VBA code that will delete all cell
contents for all the unlocked cells in a sheet?

Rob







--

Dave Peterson
  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 37
Default Delete cell contents

Thanks Dave.

Rob


"Dave Peterson" wrote in message
...
Change this:
For Each r In Selection
to
For Each r In activesheet.range("a5:g200").cells



Rob wrote:

Thanks again and that is useful, but could you please provide code that
will
do a predefined range, such as A5:G200

Rob

"Gary''s Student" wrote in
message
...
Sub rob()
For Each r In Selection
If r.Locked Then
Else
r.ClearContents
End If
Next
End Sub

In this version, just Select the area you wish to clear before running
the
macro.
--
Gary''s Student - gsnu200714


"Rob" wrote:

Thankyou so much. Worked perfectly.

As an alternative for another application I have, could you also
provide
me
with the code to have cells only cleared from a specified range
instead
of
the whole sheet?

Rob

"Gary''s Student" wrote in
message
...
Sub rob()
For Each r In ActiveSheet.UsedRange
If r.Locked Then
Else
r.ClearContents
End If
Next
End Sub
--
Gary''s Student - gsnu200713


"Rob" wrote:

Could someone please provide some VBA code that will delete all
cell
contents for all the unlocked cells in a sheet?

Rob







--

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
If you delete the contents of a cell in a worksheet in a group, w jmfadg5 Excel Discussion (Misc queries) 1 May 29th 06 06:32 AM
copy paste delete cell contents Garry Excel Discussion (Misc queries) 0 March 27th 06 08:26 PM
Delete all contents of cell but one word Hayette Hasham Excel Discussion (Misc queries) 5 January 18th 06 08:20 AM
Delete row based on contents of cell AndyG Excel Discussion (Misc queries) 6 November 17th 05 10:08 PM
Delete cell contents with input to adjacent cell Ashley Frank Excel Discussion (Misc queries) 1 October 5th 05 04:28 PM


All times are GMT +1. The time now is 01:36 PM.

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

About Us

"It's about Microsoft Excel"