I have a VBA macro built in Windows and works without any issues. I'm forced to use the file on Mac and have the following issues to overcome.
1. I'm unable to view or make changes to the userform available in the file.
2. In the userform I'm allowing users to add a new list box & combo box with the click of a button. I wasn't able to add a pick list to these boxes with the ".RowSource" code. I fixed it with the code in the bold below but for some reason, the code exits to "err_here:".
Let me know what's wrong with the code.
1. I'm unable to view or make changes to the userform available in the file.
2. In the userform I'm allowing users to add a new list box & combo box with the click of a button. I wasn't able to add a pick list to these boxes with the ".RowSource" code. I fixed it with the code in the bold below but for some reason, the code exits to "err_here:".
Let me know what's wrong with the code.
VBA Code:
Private Sub cmdAdd_Click()
Dim objNewLB As Object
Dim objNewCB As Object
Dim lngUFHeight As Long
Dim lngLR_P As Long
Dim lngLR_U As Long
Const cstrProcName As String = "cmdAdd_Click"
On Error GoTo err_here
lngLR_P = tblAdmin.Cells(tblAdmin.Rows.Count, 16).End(xlUp).Row
lngLR_U = tblAdmin.Cells(tblAdmin.Rows.Count, 21).End(xlUp).Row
If lngLR_P >= 11 + glngAddCtrls Then
glngAddCtrls = glngAddCtrls + 1
'general height of UserForm
Me.Height = Me.Height + 30
lngUFHeight = 265
Set objNewLB = Me.Controls.Add("Forms.Listbox.1", True)
With objNewLB
.Name = "Listbox" & glngAddCtrls
.Left = 18
.Height = 18
.Width = 100
.Top = lngUFHeight + (28 * glngAddCtrls)
'.Caption = tblAdmin.Range("U" & glngAddCtrls + 9).Value
.RowSource = tblAdmin.Name & "!U12:U" & lngLR_U
[B] objNewLB.List = tblAdmin.Name & "!U12:U" & lngLR_U[/B] 'new code
End With
Set objNewCB = Me.Controls.Add("Forms.combobox.1", True)
With objNewCB
.Name = "Combobox" & glngAddCtrls
.Left = 122
.Height = 18
.Width = 108
.Style = 2
.Top = lngUFHeight + (28 * glngAddCtrls)
.RowSource = tblAdmin.Name & "!P12:P" & lngLR_P
End With
lngUFHeight = 294
With cmdAdd
.Left = 40
.Top = lngUFHeight + (28 * glngAddCtrls)
End With
With cmdProc
.Left = 144
.Top = lngUFHeight + (28 * glngAddCtrls)
End With
lngUFHeight = 328
With Label9
.Left = 90
.Top = lngUFHeight + (28 * glngAddCtrls)
If glngAddCtrls > 0 Then
.Caption = glngAddCtrls & " Field(s) Added"
End If
End With
Else
MsgBox "Please check the data in '" & gwkbImport.FullName & vbCrLf & _
"as the number of Headers to import does not equal at least '" & _
8 + glngAddCtrls, vbInformation, "Not enough data"
Unload Me
End If
end_here:
On Error GoTo 0
Exit Sub
[B]err_here:
Debug.Print "Actual procedure name: " & cstrProcName & vbCrLf & _
"Error number: " & Err.Number & vbCrLf & _
"Error description: " & Err.Description
Err.Clear[/B]
On Error GoTo 0
Resume end_here
End Sub