Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default Clearing cell contents

Hi,

I have the following bit of vba which works fine:

Worksheets("sheet1").Columns("A:E").ClearContents

What I would like to do is have it so that it doesn't delete the contents in
the first row. I know I could clear the contents using rows in the bit of
code instead of columns but there could potentially be hundreds of rows of
data so I wouldn't be able to specify a range.

Is there are way of deleting the contents from columns but exclude a
specific row?

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Clearing cell contents

Hi Gina,

Try something like:

'=============
Public Sub Tester()
Dim rng As Range

With ActiveSheet
Set rng = Intersect(.UsedRange, .Columns("A:E"))
End With

Set rng = rng.Offset(1).Resize(rng.Rows.Count - 1)

rng.ClearContents
End Sub
'<<=============


---
Regards,
Norman



"Gina" wrote in message
...
Hi,

I have the following bit of vba which works fine:

Worksheets("sheet1").Columns("A:E").ClearContents

What I would like to do is have it so that it doesn't delete the contents
in
the first row. I know I could clear the contents using rows in the bit of
code instead of columns but there could potentially be hundreds of rows of
data so I wouldn't be able to specify a range.

Is there are way of deleting the contents from columns but exclude a
specific row?

Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default Clearing cell contents

Thanks, that worked perfectly.


"Norman Jones" wrote:

Hi Gina,

Try something like:

'=============
Public Sub Tester()
Dim rng As Range

With ActiveSheet
Set rng = Intersect(.UsedRange, .Columns("A:E"))
End With

Set rng = rng.Offset(1).Resize(rng.Rows.Count - 1)

rng.ClearContents
End Sub
'<<=============


---
Regards,
Norman



"Gina" wrote in message
...
Hi,

I have the following bit of vba which works fine:

Worksheets("sheet1").Columns("A:E").ClearContents

What I would like to do is have it so that it doesn't delete the contents
in
the first row. I know I could clear the contents using rows in the bit of
code instead of columns but there could potentially be hundreds of rows of
data so I wouldn't be able to specify a range.

Is there are way of deleting the contents from columns but exclude a
specific row?

Thanks




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
Clearing cell contents on CellUpdate loopoo Excel Programming 1 November 14th 05 01:16 PM
Clearing Contents of Cell Burt Excel Worksheet Functions 1 May 4th 05 02:46 PM
Clearing Cell Contents Lester Excel Programming 2 June 18th 04 10:31 PM
Clearing Cell Contents Lee Excel Programming 2 February 11th 04 10:23 PM
Clearing cell contents automatically Tom Ogilvy Excel Programming 2 August 21st 03 04:07 AM


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