Excel 2003 visual basic for 'spinbutton'
Hi Browny,
In the worksheet module,
try something like:
'==========
Option Explicit
Private iOffset As Long
'--------------
Private Sub SpinButton1_SpinDown()
Dim SH As Worksheet
Dim Rng As Range
Dim Rng2 As Range
Dim i As Long
Set SH = ThisWorkbook.Sheets("Sheet2") '<<==== CHANGE
Set Rng = SH.Range("A1:G15")
i = Rng.Rows.Count
Set Rng2 = Rng.Offset(i * iOffset)
Application.Goto Reference:=Rng2, _
Scroll:=True
iOffset = iOffset + 1
End Sub
'--------------
Private Sub SpinButton1_SpinUp()
Dim SH As Worksheet
Dim Rng As Range
Dim i As Long
Set SH = ThisWorkbook.Sheets("Sheet2") '<<==== CHANGE
Set Rng = SH.Range("A1:G15")
i = Rng.Rows.Count
If Not iOffset = 0 Then
iOffset = iOffset - 1
End If
Set Rng2 = Rng.Offset(i * iOffset)
Application.Goto Reference:=Rng2, _
Scroll:=True
End Sub
'<<==========
---
Regards.
Norman
"Browny" wrote in message
...
i'm experimenting with 'spin buttons' and want each click of the button to
display an array of cells from another sheet .e.g click 1 displays A1:G15
from sheet1 and displays in sheet2, next click dislpays A16:G31 and so on.
In
other words 'scrolling'
I can get it to work once but for the first click but not the second
click.
What is the secret to the second, third etc. click to get the function i
require?
Am i using the correct button?
Ahhhhhh!
--
Browny
|