Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Worksheet_Change event problem

Hi Guys,

I have a workbook that has around ten sheets in it with a master sheet that
collates results/totals. Data comes in via web queries.

I'm using the Worksheet_Change event to do some calculations and then to
copy 10 rows of data to my master sheet. In the mastersheet I only want to
see the last row of the ten copied as that contains the info I need to see
quickly.

I have been trying with this line of code inside the Worksheet_Change event
but have been getting nothing. Not even an error. However if I run same
line of code via a sub in a module or even in the immediate window it works
fine.

Here's the line...[assume sheet2 has focus, but it's not important]

Sheet1.Range(Cells(Rows.count, "A").End(xlUp).Offset(-1, 0), _
Cells(Rows.count, "A").End(xlUp).Offset(-9, 0)).EntireRow.Hidden = True


I have also tried....

Range(Sheet1.Cells(Rows.count, "A").End(xlUp).Offset(-1, 0), Sheet1 _
..Cells(Rows.count, "A").End(xlUp).Offset(-7, 0)).EntireRow.Hidden _
= True


I've split the code line here for display purposes but it's all one line in
my editor.

Any ideas what I've missed here?

Thanks in advance.

Ron
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Worksheet_Change event problem

Code in a sheet always defaults to the sheet that it is in. Code in a module
defaults to the active sheet. As a guess that is where your code is messing
up...

with Sheet1
..Range(.Cells(Rows.count, "A").End(xlUp).Offset(-1, 0), _
..Cells(Rows.count, "A").End(xlUp).Offset(-9, 0)).EntireRow.Hidden = True
end with

Note I have added dots before Cells so that the reference is explicilty to
Sheet1
--
HTH...

Jim Thomlinson


"Ron" wrote:

Hi Guys,

I have a workbook that has around ten sheets in it with a master sheet that
collates results/totals. Data comes in via web queries.

I'm using the Worksheet_Change event to do some calculations and then to
copy 10 rows of data to my master sheet. In the mastersheet I only want to
see the last row of the ten copied as that contains the info I need to see
quickly.

I have been trying with this line of code inside the Worksheet_Change event
but have been getting nothing. Not even an error. However if I run same
line of code via a sub in a module or even in the immediate window it works
fine.

Here's the line...[assume sheet2 has focus, but it's not important]

Sheet1.Range(Cells(Rows.count, "A").End(xlUp).Offset(-1, 0), _
Cells(Rows.count, "A").End(xlUp).Offset(-9, 0)).EntireRow.Hidden = True


I have also tried....

Range(Sheet1.Cells(Rows.count, "A").End(xlUp).Offset(-1, 0), Sheet1 _
..Cells(Rows.count, "A").End(xlUp).Offset(-7, 0)).EntireRow.Hidden _
= True


I've split the code line here for display purposes but it's all one line in
my editor.

Any ideas what I've missed here?

Thanks in advance.

Ron

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Worksheet_Change event problem


Hi Jim,

Just the ticket. Worked a treat, thanks a lot.

Ron




wrote in
:

Code in a sheet always defaults to the sheet that it is in. Code in a
module defaults to the active sheet. As a guess that is where your
code is messing up...

with Sheet1
.Range(.Cells(Rows.count, "A").End(xlUp).Offset(-1, 0), _
.Cells(Rows.count, "A").End(xlUp).Offset(-9, 0)).EntireRow.Hidden =
True end with

Note I have added dots before Cells so that the reference is
explicilty to Sheet1


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
Worksheet_Change Event problem in 2007 Chuck M Excel Programming 0 September 18th 07 05:54 PM
Worksheet_Change event Sandy Excel Programming 3 August 4th 07 12:23 PM
How do I change a Worksheet_change event to a beforesave event? Tueanker Excel Programming 5 June 29th 07 03:00 PM
Problem with Data Validation Dropdown List / Worksheet_Change Event [email protected] Excel Programming 1 August 9th 06 10:21 PM
Problem with Worksheet_Change event Romuald Excel Programming 2 January 19th 04 09:41 AM


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