Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 204
Default deleting a range

Could you please tel me why this wouldn't work

Sheets("a lap").Range(Cells(Target.Row, MaxCol + 4), Cells(Target.Row, _
256)).ClearContents

I'm running it from some code in a sheet called A grade if that makes a
difference.
Maxcol is dim as integer.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default deleting a range

Hi,

You don't say how your setting target.row or maxcol and I think you may mean
activecell.row instead of target .row, try this

maxcol = 5
Sheets("a lap").Range(Sheets("a lap").Cells(ActiveCell.Row, maxcol + 4),
Sheets("a lap").Cells(ActiveCell.Row, 256)).ClearContents

Note I've manually set maxcol.

Mike

"NDBC" wrote:

Could you please tel me why this wouldn't work

Sheets("a lap").Range(Cells(Target.Row, MaxCol + 4), Cells(Target.Row, _
256)).ClearContents

I'm running it from some code in a sheet called A grade if that makes a
difference.
Maxcol is dim as integer.

Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default deleting a range

what have you Dim'ed Target as?

Also could you post a bit more of the code so i can see where the values are
being set.
--
Kevin Smith :o)


"NDBC" wrote:

Could you please tel me why this wouldn't work

Sheets("a lap").Range(Cells(Target.Row, MaxCol + 4), Cells(Target.Row, _
256)).ClearContents

I'm running it from some code in a sheet called A grade if that makes a
difference.
Maxcol is dim as integer.

Thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 204
Default deleting a range

Mike thanks, worked a treat. The target.row part was fine, just needed the
extra sheets("a lap").cells..... in the range part of the statement.



"NDBC" wrote:

Could you please tel me why this wouldn't work

Sheets("a lap").Range(Cells(Target.Row, MaxCol + 4), Cells(Target.Row, _
256)).ClearContents

I'm running it from some code in a sheet called A grade if that makes a
difference.
Maxcol is dim as integer.

Thanks

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default deleting a range

The problem is that your Cells function isn't (necessarily) pointing
to the worksheet "a lap". Because it is unqualified (doesn't have a
worksheet prefix), it points to the either the ActiveSheet if the
code is in a regular module, or the worksheet in which the code
resides. Use

With Sheets("a lap")
.Range(.Cells(Target.Row, MaxCol + 4), _
.Cells(Target.Row, 256)).ClearContents
End With

Note the leading periods.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)





On Fri, 4 Sep 2009 01:51:05 -0700, NDBC
wrote:

Could you please tel me why this wouldn't work

Sheets("a lap").Range(Cells(Target.Row, MaxCol + 4), Cells(Target.Row, _
256)).ClearContents

I'm running it from some code in a sheet called A grade if that makes a
difference.
Maxcol is dim as integer.

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
Deleting range Orlando Excel Programming 1 September 7th 07 04:04 AM
Deleting a range Don Guillett Excel Programming 1 January 9th 07 05:42 PM
Deleting Range name's listed in the range address box. Satnam Patel Excel Discussion (Misc queries) 4 May 5th 05 01:42 PM
Deleting Range using VB sjbeeny Excel Programming 5 May 29th 04 12:14 PM
Deleting range not a row Robert[_13_] Excel Programming 3 September 1st 03 11:12 PM


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