LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
Don Don is offline
external usenet poster
 
Posts: 487
Default "Scrolling with Scrollbar or SpinButton on UserForm"

It's me again...everything is working fine so far...but I have two
questions... How do I code this scrollbar so that it opens on the last value?
Here's what I've done so that the scrollbar has an open blank cell at the
bottom, I'd like the TextBoxes to open in this blank Row:


Private Sub UserForm_Initialize()
LstCell = [A65535].End(xlUp).Row 'Find last used cell in column A
ScrollBar1.Min = 4 'Set Min and Max value to scroll bar
ScrollBar1.Max = LstCell + 1 '<<<increased by one to the first empty cell
End Sub

Second Question:

Here is my code for entering the data onto the WS:

Private Sub CmdBtn1_Click()
Range("A" & SetRow).Value = TextBox1.Value
Range("B" & SetRow).Value = TextBox2.Value
Range("C" & SetRow).Value = TextBox3.Value
Range("D" & SetRow).Value = TextBox4.Value
Range("E" & SetRow).Value = TextBox5.Value
Range("F" & SetRow).Value = TextBox6.Value
Range("G" & SetRow).Value = TextBox7.Value
Range("H" & SetRow).Value = TextBox8.Value
Range("I" & SetRow).Value = TextBox9.Value
Range("J" & SetRow).Value = TextBox10.Value
Unload UserForm1
UserForm1.Show
End Sub

Is adding the Unload and Show command the best way to get to the next empty
line after entering data?

Thanks again for all your help... Don

"Incidental" wrote:

Hi Don

It sounds like you could just use the built in Form found under the
Data menu in the main excel app. I have included some code below that
should do what you are after. To test put four textboxes and a
scrollbar on a userform and then paste the following code into the
userform code module and of course add some data to the columns A - D.

Option Explicit
Dim LstCell As Integer
Dim SetRow As Integer
Dim i As Integer
Dim Ctrl As MSForms.Control 'Alway declare your variables

Private Sub ScrollBar1_Change()

SetRow = ScrollBar1.Value 'Pass scrollbar value to a variable

Range("A" & SetRow).Activate 'Select a row using that variable

For i = 1 To 4 'Second number is the total No of textboxes

Set Ctrl = UserForm1.Controls("TextBox" & i) 'Select a textbox

Ctrl.Value = ActiveCell.Value 'Show cell value in textbox

ActiveCell.Offset(0, 1).Activate 'Offset cell for the next pass

Next 'Iterate textbox

Range("A" & SetRow).Activate 'Reselect the first column for when you
save

End Sub

Private Sub UserForm_Initialize()

LstCell = [A65535].End(xlUp).Row 'Find last used cell in column A

ScrollBar1.Min = 1 'Set Min and Max value to scroll bar

ScrollBar1.Max = LstCell

End Sub

Hope this Helps

S




 
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
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
Cells may look "empty" when quickly scrolling up or down DoctorG Excel Discussion (Misc queries) 2 August 21st 07 02:22 PM
Scrolling and quick key shortcuts for a "Drop-Down-List" makten86 Excel Discussion (Misc queries) 0 February 7th 06 10:22 PM
How to stop "Synchronized Scrolling" in Excel Workbook comparing sagorb Excel Worksheet Functions 1 February 6th 06 10:50 PM
Getting a spinbutton / scrollbar to "repeat" Fred Holmes Excel Programming 0 December 23rd 04 08:30 PM


All times are GMT +1. The time now is 02:54 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"