Excel VBA USERFORMS #3 Custom Code When Userform Loads/Initializes, Fill Combobox Dynamically

preview_player
Показать описание


Fantastic Developer Tools:
Рекомендации по теме
Комментарии
Автор

For your
If (lastrow stuff) = 1 then
sdLR=2
else
sdLR = (lastrow stuff)
end if

Wouldn't it just be easier (and faster) if you just use:
sdLR = sdsheets.cells(rows.coutn, 1).end(xlup).row + 1

That way you save your self 5 lines of code. Unless you really need that last row to be truely the last row. I'm not sure what's faster (I guess it depends on what you're doing), going through that extra if statement everytime, or evaluating an extra row every time.

Just a thought.

galleguilloscastro
Автор

Hi I was wondering if you could show how to limit the number of characters and types of characters that can be entered into the Text box?

jlpayne
Автор

If you would like to update the comboBox with the new values after sorting here is the code:
go to the worksheet you are working on then select "Worksheet_SelectionChange"

'Change the variable names accordingly to match the existing code on the video :)

Private Sub Target As Range)

Dim sdsheet As Worksheet
Set sdsheet =

Lastrow = Cells(Rows.Count, 1).End(xlUp).Row
sortForm.cmbox.Clear

For x = 2 To Lastrow
sortForm.cmbox.AddItem sdsheet.Cells(x, 1) & " - " & sdsheet.Cells(x, 2)
Next x



End Sub

KlaydPro
Автор

Hi Dan the video was absolutely helpful for me and also I'm a big fan of yours :), however can you do codes for filling up unique values in the combo box within userform, which lists come from a range from a certain worksheet.

Thanks and Cheers

edtardaguila
Автор

brunwynne, it sounds like at the end of your code (if in a worksheet or module), you may need to add the userform's name and dot (.) show. So if the userform is named Userform1, you'd add a line that says

Userform1.Show

If that's not helpful, please copy/paste some of the offending code, we'll try and troubleshoot. Thanks!! Daniel

ExcelVbaIsFun
Автор

Hi Where is the workbook for this lesson?

shereesingh
Автор

Is there a way to dynamically change the font in a user form?  I have a name(s) that get displayed in the title of my form and if the list gets too long the bottom part is lost to view.  Could I have it automatically resize to fit in the box?

bkhohnst
Автор

Merry Christmas everyone. I hope God blesses you richly this upcoming year. Remember, you ARE a success!! Believe it, be it! Blessings my friends!! Dan

ExcelVbaIsFun
Автор

Hi Dan, is there a way to control a code from a userform? for example, if you have a code that says. If textbox1.text = "THIS IS THE PASSWORD" then msgbox = "correct". would you be able to change the password from a userform? 

magiadecine
Автор

Hi - Thanks your videos are excellent. But in a few ones including this one, I typed the exact code and steps in your video and got error messages or the form doesn't work. May be I am making mistakes but you might be forgetting to show some of the things you had already done. It would be more interesting if you had started from a blank document with only the data on the wks. Good job though!

funkidsstories
Автор

My form doesn't show....It appears to cycle throught the rows, but the form itself does not appear unless I run this macro right from the "view code" for the form itself.

thoughts?

brunwynne
Автор

Where "cmbEmp" does com from?

mariuszkrukar
Автор

Hi Dan. I have a quick question. I have a form that uses a combo box for "Names" and I am able to load it when the form initializes as you have shown here. In the event that the user wants to add another "name" I have included a button on the form so that a "add a name" form opens on top of the first form. The user can then add another name which is stored on a data sheet as you have shown in your videos.

The problem is, when this second form closes, and the first form becomes re-activated, I can't seem to get the combo box to update with the new names that the user just added. I looked for another event other than "initialize" such as "get focus" but I don't see anything that will get the job done. Any ideas?

teachmeautocad
Автор

Hi Dan, I have a question and the only answers I found on the internet seem so contrived and convoluted and even that which I have tried I haven’t been able to get it to work.
1. I have a Userform, and I want to put all my functions in separate modules, preferable in the Personal.xlsb workbook, but at the moment I’m putting them in the current project workbook.
2. In one of the functions I want to return an array string, and I can’t find out how to do it.
3. If the function is in the Userform code then it’s not a problem because I can declare the array before the main Sub, but as soon as I stick my function in a separate module then the array is not accessible.
Any suggestions.
Regards Joe

joecampanini
Автор

Just love the lessons and am learning heaps BUT for some reason I am get a compile error on my copy of your script

For x = 2 To lr

    mssheet.Cells(x, 5) & " - " & mssheet.Cells(x, 6)
    
Next x

I get Compile error   expected :=       and the middle line in red text with the first & highlighted.
The only difference is my sheet is mssheet not sdsheet. I have a space between all the characters between the two fields to be joined.

stockjg
Автор

i think you are not teaching you are just making some time pass man.

akgamingworld