Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Use Macro To Change Which Macro Assigned To Command Button | Excel Discussion (Misc queries) | |||
Run a macro using a command button | Excel Discussion (Misc queries) | |||
Run Macro from Command Button | Excel Discussion (Misc queries) | |||
Macro/Command Button | Excel Programming | |||
Command Button & Macro | Excel Programming |