Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Abi Abi is offline
external usenet poster
 
Posts: 20
Default Button Macro - One command but does two things ???

I created a simple button at the top of a sheet that, when clicked, takes the
user from line 150 (2-148 are hidden) down to cell A315.

The VB reads:
Private Sub CommandButton8_Click()
ActiveWindow.SmallScroll Down:=165
End Sub

Here's what's going on:
1. Open the sheet.
2. Click the button. Taken to line 167 at top of view (no specific cell
focus)
3. Scroll up and click again. Taken to bottom where it should be (no cell
focus)
4. If I use another button I created to take user back up to top, with the
following VB:
Private Sub CommandButton9_Click()
ActiveWindow.SmallScroll Up:=126
Range("B150").Select
End Sub
Taken to top, focus is in cell B150 (where it should be)

5. If I try to click the button to go back down again, nothing happens.
6. Click in any other cell and then click button. Taken to line 167 (no
cell focus)

What's going on with the screwy looping? Am I not using the proper
commands? How does it work sometimes and not others?

Thanks!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default Button Macro - One command but does two things ???

Here is the basics of the code you need...

for command button 8 use this code
range("B167").select
activecell.show

for command button 9 use this code
range("B150").select
activecell.show

HTH

"Abi" wrote:

I created a simple button at the top of a sheet that, when clicked, takes the
user from line 150 (2-148 are hidden) down to cell A315.

The VB reads:
Private Sub CommandButton8_Click()
ActiveWindow.SmallScroll Down:=165
End Sub

Here's what's going on:
1. Open the sheet.
2. Click the button. Taken to line 167 at top of view (no specific cell
focus)
3. Scroll up and click again. Taken to bottom where it should be (no cell
focus)
4. If I use another button I created to take user back up to top, with the
following VB:
Private Sub CommandButton9_Click()
ActiveWindow.SmallScroll Up:=126
Range("B150").Select
End Sub
Taken to top, focus is in cell B150 (where it should be)

5. If I try to click the button to go back down again, nothing happens.
6. Click in any other cell and then click button. Taken to line 167 (no
cell focus)

What's going on with the screwy looping? Am I not using the proper
commands? How does it work sometimes and not others?

Thanks!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 176
Default Button Macro - One command but does two things ???

2. Click the button. Taken to line 167 at top ..
I get 166 (1 + 165 seems right). No problem.

5. If I try to click the button to go back down again, nothing happens.

The buttons work for me (XL97).
But it seems more straightforward to:

Private Sub CommandButton8_Click()
Cells(167, 1).Select
ActiveWindow.SmallScroll Down:=5 ' or whatever you want
End Sub

Private Sub CommandButton9_Click()
Range("B150").Select
ActiveWindow.SmallScroll up:=2
End Sub

Abi wrote:
I created a simple button at the top of a sheet that, when clicked, takes the
user from line 150 (2-148 are hidden) down to cell A315.

The VB reads:
Private Sub CommandButton8_Click()
ActiveWindow.SmallScroll Down:=165
End Sub

Here's what's going on:
1. Open the sheet.
2. Click the button. Taken to line 167 at top of view (no specific cell
focus)
3. Scroll up and click again. Taken to bottom where it should be (no cell
focus)
4. If I use another button I created to take user back up to top, with the
following VB:
Private Sub CommandButton9_Click()
ActiveWindow.SmallScroll Up:=126
Range("B150").Select
End Sub
Taken to top, focus is in cell B150 (where it should be)

5. If I try to click the button to go back down again, nothing happens.
6. Click in any other cell and then click button. Taken to line 167 (no
cell focus)

What's going on with the screwy looping? Am I not using the proper
commands? How does it work sometimes and not others?

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
Use Macro To Change Which Macro Assigned To Command Button CVinje Excel Discussion (Misc queries) 0 May 25th 10 09:55 PM
Run a macro using a command button Tdahlman Excel Discussion (Misc queries) 9 March 5th 08 07:59 PM
Run Macro from Command Button [email protected] Excel Discussion (Misc queries) 1 April 23rd 07 04:36 PM
Macro/Command Button Howard Excel Programming 7 August 21st 04 12:08 AM
Command Button & Macro alexm999[_10_] Excel Programming 2 January 28th 04 09:12 PM


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