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

Hi! I am trying to clear contents in a range of cells but i fail with the
syntax. I want to clear contents starting at cell D5. I want the clear
contents to end where there is nothing more to the right of cell D5 and then
go down to find the last cell with content. I have tried to do that with the
code below but it is somehow wrong. any help appreciated! thanks alot!

ActiveSheet.Range(Cells(5, 4), Cells(Range("C5").End(xlDown).Row,
Range("d5").End(xlToRight))).ClearContents
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 272
Default Clear contents

Forgot .Column...
ActiveSheet.Range(Cells(5, 4), Cells(Range("C5").End(xlDown).Row, _
Range("d5").End(xlToRight).Column)).ClearContents
--
Charles Chickering

"A good example is twice the value of good advice."


"Arne Hegefors" wrote:

Hi! I am trying to clear contents in a range of cells but i fail with the
syntax. I want to clear contents starting at cell D5. I want the clear
contents to end where there is nothing more to the right of cell D5 and then
go down to find the last cell with content. I have tried to do that with the
code below but it is somehow wrong. any help appreciated! thanks alot!

ActiveSheet.Range(Cells(5, 4), Cells(Range("C5").End(xlDown).Row,
Range("d5").End(xlToRight))).ClearContents

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 272
Default Clear contents

Oh, and did you mean "D5" for the row?
ActiveSheet.Range(Cells(5, 4), Cells(Range("D5").End(xlDown).Row, _
Range("d5").End(xlToRight).Column)).ClearContents

Alternatively, if there is nothing connected above and to the left of "D5"
you can use the CurrentRegion Property:
Range("D5").CurrentRegion.ClearContents
--
Charles Chickering

"A good example is twice the value of good advice."


"Charles Chickering" wrote:

Forgot .Column...
ActiveSheet.Range(Cells(5, 4), Cells(Range("C5").End(xlDown).Row, _
Range("d5").End(xlToRight).Column)).ClearContents
--
Charles Chickering

"A good example is twice the value of good advice."


"Arne Hegefors" wrote:

Hi! I am trying to clear contents in a range of cells but i fail with the
syntax. I want to clear contents starting at cell D5. I want the clear
contents to end where there is nothing more to the right of cell D5 and then
go down to find the last cell with content. I have tried to do that with the
code below but it is somehow wrong. any help appreciated! thanks alot!

ActiveSheet.Range(Cells(5, 4), Cells(Range("C5").End(xlDown).Row,
Range("d5").End(xlToRight))).ClearContents

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 246
Default Clear contents

I think the last bit is missing ".column"
So Range("d5").End(xlToRight) needs .column tagged on the end

Regards
J

Arne Hegefors wrote:

Hi! I am trying to clear contents in a range of cells but i fail with the
syntax. I want to clear contents starting at cell D5. I want the clear
contents to end where there is nothing more to the right of cell D5 and then
go down to find the last cell with content. I have tried to do that with the
code below but it is somehow wrong. any help appreciated! thanks alot!

ActiveSheet.Range(Cells(5, 4), Cells(Range("C5").End(xlDown).Row,
Range("d5").End(xlToRight))).ClearContents


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 Contents gibbylinks Setting up and Configuration of Excel 5 October 12th 09 05:04 PM
Clear Contents Secret Squirrel Excel Discussion (Misc queries) 1 February 3rd 09 12:37 AM
Macro to clear range contents when cell contents are changed by us Steve E Excel Programming 12 February 22nd 07 09:09 PM
Clear contents SamanthaK Excel Programming 3 June 15th 06 09:05 AM
Clear contents if x is not in the row Mighvik Excel Programming 1 October 5th 04 08:14 PM


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