Show_form() Marco in Excel VBA is not working

aabrazil1

New Member
Joined
Feb 11, 2024
Messages
19
Office Version
  1. 2021
Platform
  1. Windows
I am learning VBA and following this youtube lesson:


I copied his code exact and when I assign the Show_form() macro to my shape on the work sheet the macro highlights yellow. Please see below:

1707689947589.png


Here's the 3 macros I wrote per the youtube:

Sub Reset()

Dim iRow As Long
iRow = [Counta(Database!A:A)] ' identify the last row
With frmform

.txtID.Value = " "
.txtName.Value = " ' "
.OptMale.Value = False
.OptFemale.Vlaue = False

.cmbDepartment.Clear

.cmbDepartment.AddItem "HR"
.cmbDepartment.AddItem "Operation"
.cmbDepartment.AddItem "Training"
.cmbDepartment.AddItem " Quality"

.txtCity.Value = " "
.txtCountry = " "

.lstDatabase.ColumnCount = 9
.lstDatabase.ColumnHeads = True

.lstDatabase.ColumnWidths = "30,60,75,40,60,45,55,70,70"

If iRow > 1 Then

.lstDatabase.RowSource = "Database!A2:I" & iRow
Else

.lstDatabase.RowSource = "Database!A2:I2"

End If

End With

End Sub


Sub Submit()

Dim sh As Worksheet
Dim iRow As Long
Set sh = ThisWorkbook.Sheets("Database")
iRow = [Counta(Database!A:A] + 1
With sh

.Cells(iRow, 1) = iRow - 1

.Cells(iRow, 2) = frmform.txtID.Value

.Cells(iRow, 3) = frmform.txtName.Value

.Cells(iRow, 4) = IIf(frmform.OptFemale.Value = True, "Female", "Male")

.Cells(iRow, 5) = frmform.cmbDepartment.Value

.Cells(iRow, 6) = frmform.txtCity.Value

.Cells(iRow, 7) = frmform.txtCountry.Value

.Cells(iRow, 8) = Application.UserName

.Cells(iRow, 9) = [Text(Now(),"DD-MM-YYYY HH:MM:SS")]

End With


End Sub

Sub Show_form()

frmform.Show

End Sub


Thank you,
Tony
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Hi
welcome to forum
You have not stated the error message you are getting but assuming that you have posted all your userforms code and as guess you are getting 424 Object Required?
If this is so, check that you have named your userform correctly

Also, noticed that you have a typo in your Reset code

Rich (BB code):
  .OptFemale.Vlaue = False

It should Value

To help forum, Please take time to have a read here: How to Post Your VBA Code

Dave
 
Upvote 0
Solution

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

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