Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Excel 2003 visual basic for 'spinbutton'
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 |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Excel 2003 visual basic for 'spinbutton'
Hi Norman
Im having trouble with it. Would it be too much to ask for a greater explanation? Im not sure where to substitute my data for that required by Vbasic. To explain, My spin button is in sheet2 By clicking on the spin button (up) I want to copy a selected group of cells A1:Q12 from sheet1 and paste into sheet2 A5:Q17, when I spin (down) I want another group of cells to be copied. Ultimately Im looking to browse thru sheet1 by clicking the spin button up/dwn and read the selected group of cells (from sheet1) in sheet2. Im not even sure Im using the correct command (spin button) maybe theres a better way, Can you advise -- Browny "Norman Jones" wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
visual basic compile error in excel 2003 | Excel Discussion (Misc queries) | |||
Visual Basic module from Excel 2003 crashing in Excel 2007 | Excel Discussion (Misc queries) | |||
Visual BASIC in Excel | Excel Worksheet Functions | |||
Visual Basic Function works fine in Excell 2003 but not in Excel 2 | Excel Discussion (Misc queries) | |||
changing the visual basic in office 2003 to visual studio net | Excel Discussion (Misc queries) |