New UserForm fill

ebea

Board Regular
Joined
Jul 12, 2008
Messages
217
Office Version
  1. 2013
Platform
  1. Windows
Hi all. A mystery for me, to have info to fill into a second UserForm, called from a Button on the main userForm.
I have a functioning UserForm, which are loaded from a workbook load event. It have many TexBoxes and one Picture form. All that works perfectly, with the following code, (which are only a part of the whole load code).

Private Sub CommandButton1_Click()

Dim rws As Long, Box As String, LstRw As Long, Sh As Worksheet

Set Sh = Sheets("marklin")
Box = TextBox14.Value
With Sh
LstRw = .Cells(.Rows.Count, "B").End(xlUp).Row
For rws = 3 To LstRw
If .Range("B" & rws).Value = Box Then

TextBox2.Value = .Range("B" & rws).Value
TextBox1.Value = .Range("T" & rws).Value
Image1.Picture = LoadPicture(("F:\tog\pdf\digital\") & Range("T" & rws).Value)

End If
Next rws
End With

I then have insert a new Comman Button on the original UserForm, from where I want to call the new UserForm, and in reality load nearly same info, and from same Sheet, as the other TextBoxes are loaded from.
And it's her my problem are. No matter what I try of code combinations, nothing will be loaded into the new UserForm.

For me, it's like that I can't get focus from the Sheet where the data should be loaded from.

In reality, I should could use the same code, as listed above; but it also not works.

Are there a kind person, who have "the wise Stones"!

Thanks
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

EXCEL MAX

Active Member
Joined
Nov 11, 2020
Messages
392
Office Version
  1. 2016
Platform
  1. Windows
This is correct code and should work for itself, but there can be many reasons that confuses code.
Try this...
1. When you switching between few UserForms always put name of the of the correct UserForm before name of the control.
2. Take care that declarations exists in the each UserForm.
3. Check names of each control.
4. If you have many procedures in one module, be sure some control not have open empty duplicate code.
 
Last edited:

ebea

Board Regular
Joined
Jul 12, 2008
Messages
217
Office Version
  1. 2013
Platform
  1. Windows
This is correct code and should work for itself, but there can be many reasons that confuses code.
Try this...
1. When you switching between few UserForms always put name of the of the correct UserForm before name of the control.
2. Take care that declarations exists in the each UserForm.
3. Check names of each control.
4. If you have many procedures in one module, be sure some control not have open empty duplicate code.
I tried many combinations, and code pieces, but still without any luck. I simply run out of ideas, and can't find the solution. My second Form loads fine, and the code showed up, works without any errors. I even tested with a TextBox to be equal to TextBox on the other Form, but still no data are filled in!
 

Watch MrExcel Video

Forum statistics

Threads
1,130,441
Messages
5,642,133
Members
417,258
Latest member
amk1979

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
Top