Userform reload on open

rutger

Board Regular
Joined
Apr 5, 2005
Messages
74
Hey there,
i have a question.
i have a userform that contains all data from a company.
It gets the data from a heet called "companies".
The userform is opened by clicking a button on another userform("menu").
This far it works ok.
The problem is that i have more companies in that one sheet that i want to call from that one userform ( so when the button company2 on the menu is pressed it open's the data userform and displays the data from that company.
On the sheet "Companies" all the data for each company is in the same location except 50 rows lower.
I don't know how i can easily call those different rows.

I tried sopmething like:


Code:
Public Sub UserForm_Activate()
Dim T As String



Label18.Caption = "U bent ingelogd als: " & Login!Name.Value
Label1.Caption = TextBox1.Value

Site!TextBox1.Value = [Sheets]![Sites].Cells(40 + T, 1).Value
Site!TextBox2.Value = [Sheets]![Sites].Cells(40 + T, 2).Value
Site!TextBox3.Value = [Sheets]![Sites].Cells(40 + T, 3).Value
Site!TextBox4.Value = [Sheets]![Sites].Cells(40 + T, 4).Value

in this i want to define T in every button click event
i.e.

Code:
Private Sub CommandButton17_Click()
Dim T As String
T = "50"

If anyone can help me i would greatly appreciate it


Greetz,
Rutger
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Sorry, maybe it's just me, but I don't understand what you mean.

What data do you want on the userform
 
Upvote 0
hmmm, let me try it again

Basically, what i want is this:

I want to load data into the textboxes in a userform whenever that userform is opened.
It will be opened from different buttons on another userform.
If it is openend trough button A I want it to load data from companie A, if it is openend trough button B i want it to load data from companie B etc.
The data is all stored in a sheet.
If companie A is stored in cell A1 then company B is stored in cell A50 and so on.
I found out how i can get the data of compay A into my userform and i can also clear all textboxes when i hide the userform. Now i need to find way to make this line:
Code:
Site.TextBox1.Value = [Sheets]![Sites].Cells(40, 1).Value
flexible so that when button B is pressed the value 40 will change into 40 + 50 = 90.

I hope this makes it more clear

Greets,
Rutger
p.s. and thanks for helping
 
Upvote 0

Forum statistics

Threads
1,224,352
Messages
6,178,071
Members
452,822
Latest member
MtC

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top