Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default won't select cell on another sheet


I have a large amount of data (over 500,000 rows) so I have spread thi
data over multiple sheets. The code I have written has to find record
that match certain criteria and does this by looping through cells
However, when it reaches the bottom of the first sheet (row 65536)
need it to start on the next sheet but I keep getting a Run time error
Here is the bit of code....

If ActiveCell.Row = 65536 And ActiveSheet.Index < 9 Then
g3000SheetNumber = ActiveSheet.Index + 1
Sheets(g3000SheetNumber ).Activate
Cells(1, 1).Select

It manages to select the new sheet but when I try to select the firs
cell of the sheet it throws an error. Can anyone help please?

--
smit12
-----------------------------------------------------------------------
smit127's Profile: http://www.excelforum.com/member.php...fo&userid=2687
View this thread: http://www.excelforum.com/showthread.php?threadid=40109

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default won't select cell on another sheet

smit,

You would be much better off not activating or selecting anything. You are much better off using
native Excel procedures such as find - post the rest of your code or a description of what your are
doing for suggestions.

HTH,
Bernie
MS Excel MVP


"smit127" wrote in message
...

I have a large amount of data (over 500,000 rows) so I have spread this
data over multiple sheets. The code I have written has to find records
that match certain criteria and does this by looping through cells.
However, when it reaches the bottom of the first sheet (row 65536) I
need it to start on the next sheet but I keep getting a Run time error.
Here is the bit of code....

If ActiveCell.Row = 65536 And ActiveSheet.Index < 9 Then
g3000SheetNumber = ActiveSheet.Index + 1
Sheets(g3000SheetNumber ).Activate
Cells(1, 1).Select

It manages to select the new sheet but when I try to select the first
cell of the sheet it throws an error. Can anyone help please??


--
smit127
------------------------------------------------------------------------
smit127's Profile: http://www.excelforum.com/member.php...o&userid=26870
View this thread: http://www.excelforum.com/showthread...hreadid=401094



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default won't select cell on another sheet

Bernie is exactly right.

However, to answer you problem, I assume you are running this from a sheet
module rather than a general module. In a sheet module, your unqualified
Cells refers to the sheet containing the code.

Either move the code to a general module and call it from your
control/button or qualify Cells

If ActiveCell.Row = 65536 And ActiveSheet.Index < 9 Then
g3000SheetNumber = ActiveSheet.Index + 1
set sh = Sheets(g3000SheetNumber )
sh.Activate
sh.Cells(1, 1).Select

--
Regards,
Tom Ogilvy


"smit127" wrote in
message ...

I have a large amount of data (over 500,000 rows) so I have spread this
data over multiple sheets. The code I have written has to find records
that match certain criteria and does this by looping through cells.
However, when it reaches the bottom of the first sheet (row 65536) I
need it to start on the next sheet but I keep getting a Run time error.
Here is the bit of code....

If ActiveCell.Row = 65536 And ActiveSheet.Index < 9 Then
g3000SheetNumber = ActiveSheet.Index + 1
Sheets(g3000SheetNumber ).Activate
Cells(1, 1).Select

It manages to select the new sheet but when I try to select the first
cell of the sheet it throws an error. Can anyone help please??


--
smit127
------------------------------------------------------------------------
smit127's Profile:

http://www.excelforum.com/member.php...o&userid=26870
View this thread: http://www.excelforum.com/showthread...hreadid=401094



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default won't select cell on another sheet


Thanks guys. Got it working.


--
smit127
------------------------------------------------------------------------
smit127's Profile: http://www.excelforum.com/member.php...o&userid=26870
View this thread: http://www.excelforum.com/showthread...hreadid=401094

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
How can I use a cell value to select a sheet tab? Monkey-See, Monkey-Do[_2_] Excel Discussion (Misc queries) 6 October 13th 08 11:49 PM
Select sheet from cell value Grid Excel Discussion (Misc queries) 9 July 16th 07 01:02 PM
View, scroll and select a cell value from another Excel sheet? benb Excel Worksheet Functions 1 October 12th 06 05:48 AM
How do i select the first cell in a sheet ajitpalsingh200[_7_] Excel Programming 1 November 6th 04 11:01 AM
Select sheet based on cell value Dan Mills Excel Programming 2 January 14th 04 05:55 PM


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