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 cell range in a worksheet_change subroutine

I have a worksheet_change subroutine that copies selected cells to another
worksheet as they are entered. This all works fine.

My problem occurs when I try and delete data from the original worksheet. If
I only delete one cell it works fine and clears the cell in the second sheet.
If I select a range and hit delete then it only clears the activecell off the
second sheet.

Can I use code to force it to do the range.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default deleting cell range in a worksheet_change subroutine

Hi,

Maybe something like this:

RngToDelete=Selection.Address
Sheets("Sheet2").Range(RngToDelete).ClearContents

As always, it is eaisier to make an exact answer, if you posted your
current code.

Hopes it helps.
...
Per

On 4 Sep., 03:20, NDBC wrote:
I have a worksheet_change subroutine that copies selected cells to another
worksheet as they are entered. This all works fine.

My problem occurs when I try and delete data from the original worksheet. If
I only delete one cell it works fine and clears the cell in the second sheet.
If I select a range and hit delete then it only clears the activecell off the
second sheet.

Can I use code to force it to do the range.

Thanks


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 204
Default deleting cell range in a worksheet_change subroutine

Thanks, I can make that work.

My trouble now is I'm getting an error on this line

RngToDelete=Selection.Address

I'm using excel 2003 and have dim RngToDelete as range.



"Per Jessen" wrote:

Hi,

Maybe something like this:

RngToDelete=Selection.Address
Sheets("Sheet2").Range(RngToDelete).ClearContents

As always, it is eaisier to make an exact answer, if you posted your
current code.

Hopes it helps.
...
Per

On 4 Sep., 03:20, NDBC wrote:
I have a worksheet_change subroutine that copies selected cells to another
worksheet as they are entered. This all works fine.

My problem occurs when I try and delete data from the original worksheet. If
I only delete one cell it works fine and clears the cell in the second sheet.
If I select a range and hit delete then it only clears the activecell off the
second sheet.

Can I use code to force it to do the range.

Thanks



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

Just had a thought, maybe error wasn't in that line

RngToDelete = Selection.Address
Sheets("a lap").Range(RngToDelete).Offset(0, 3).ClearContents

I need to move the selection address over 3 columns to clear in the second
sheet. Have I done this wrong and it is just showing up an error on the wrong
line


"NDBC" wrote:

Thanks, I can make that work.

My trouble now is I'm getting an error on this line

RngToDelete=Selection.Address

I'm using excel 2003 and have dim RngToDelete as range.



"Per Jessen" wrote:

Hi,

Maybe something like this:

RngToDelete=Selection.Address
Sheets("Sheet2").Range(RngToDelete).ClearContents

As always, it is eaisier to make an exact answer, if you posted your
current code.

Hopes it helps.
...
Per

On 4 Sep., 03:20, NDBC wrote:
I have a worksheet_change subroutine that copies selected cells to another
worksheet as they are entered. This all works fine.

My problem occurs when I try and delete data from the original worksheet. If
I only delete one cell it works fine and clears the cell in the second sheet.
If I select a range and hit delete then it only clears the activecell off the
second sheet.

Can I use code to force it to do the range.

Thanks



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default deleting cell range in a worksheet_change subroutine

Selection.Address is returning a string, so you should use:

Dim RngToDelete As String

Regards,
Per

On 4 Sep., 04:08, NDBC wrote:
Thanks, I can make that work.

My trouble now is I'm getting an error on this line

RngToDelete=Selection.Address

I'm using excel 2003 and have dim RngToDelete as range.



"Per Jessen" wrote:
Hi,


Maybe something like this:


RngToDelete=Selection.Address
Sheets("Sheet2").Range(RngToDelete).ClearContents


As always, it is eaisier to make an exact answer, if you posted your
current code.


Hopes it helps.
...
Per


On 4 Sep., 03:20, NDBC wrote:
I have a worksheet_change subroutine that copies selected cells to another
worksheet as they are entered. This all works fine.


My problem occurs when I try and delete data from the original worksheet. If
I only delete one cell it works fine and clears the cell in the second sheet.
If I select a range and hit delete then it only clears the activecell off the
second sheet.


Can I use code to force it to do the range.


Thanks- Skjul tekst i anførselstegn -


- Vis tekst i anførselstegn -


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
Error when Target Range is block, not cell in Worksheet_Change Eve Jim Zeeb[_2_] Excel Programming 2 August 11th 06 08:16 PM
Disabling worksheet_change when deleting rows . . Adam[_14_] Excel Programming 3 February 16th 06 04:06 PM
Worksheet Cell Range Name within VB Subroutine Jay Somerset Excel Discussion (Misc queries) 5 February 6th 06 02:27 PM
Prevent error when deleting row within Worksheet_Change target ran Peter Rooney Excel Programming 0 February 1st 06 03:41 PM
subroutine to get all of the Named range properties Arishy[_2_] Excel Programming 3 June 30th 05 03:34 PM


All times are GMT +1. The time now is 06:41 AM.

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"