|
-
Dec 21st, 2009, 10:03 PM
#1
Thread Starter
New Member
[RESOLVED] Excel Userform scrollbar to show data
I have 5, TextBoxes 1- 5 that post their data to Columns A-E on Worksheet 1
I need to see the data from the workbook in Columns A-E presented in the UserForm TextBoxes 1- 5 as I scroll the ScrollBar Up & down.
Hope this is clear.
Thanks
-
Dec 22nd, 2009, 03:17 AM
#2
Re: Excel Userform scrollbar to show data
try like
vb Code:
Private Sub ScrollBar1_Change() r = ScrollBar1.Value For j = 1 To 5 Me.Controls("TextBox" & j) = Cells(r, j) Next End Sub
you will need to set properties for scrollbar to prevent going out of range, also error handling to prevent 0 from causing error
you may also want a textbox or label to show the current row being displayed
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Dec 22nd, 2009, 08:18 AM
#3
Re: Excel Userform scrollbar to show data
Simora, check the link in my signature for scrollbars...
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Dec 23rd, 2009, 05:41 AM
#4
Thread Starter
New Member
Re: Excel Userform scrollbar to show data
Thanks for the ideas.
I Used something like ths
Code:
Private Sub ScrollBar1_Change()
Dim row As Long
row = ScrLng(Me.ScrollBar1.Value)
With wks
Me.TextBox1.Text = .Cells(row, 1)
Me.TextBox2.Text = .Cells(row, 2)
' etc etc
End With
End Sub
*******************************
Private Sub UserForm_Initialize()
Set wks = Worksheets("Sheet1")
row_beginning = 2
row_ending = wks.Cells(row_beginning, 1).End(xlDown).row
With Me.ScrollBar1
.Value = row_beginning
.Min = row_beginning
.Max = row_ending
.LargeChange = 1
.SmallChange = 1
End With
Call ScrollBar1_Change
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|