Issue with Userform and List Box on MAC

bcmk29

Board Regular
Joined
Oct 20, 2022
Messages
55
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
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.

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
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
There is no accessible userform designer on a Mac in versions after 2011. Also, you cannot use RowSource with a listbox or combobox on a Mac. You have to use the List property and assign the value of the range to it.
 
Upvote 0
There is no accessible userform designer on a Mac in versions after 2011. Also, you cannot use RowSource with a listbox or combobox on a Mac. You have to use the List property and assign the value of the range to it.
@RoryA Any sample code for reference using List Property would help or you can modify the code I posted.
 
Upvote 0
You'd use something like:

VBA Code:
objNewLB.List = tblAdmin.Range("U12:U" & lngLR_U).Value
 
Upvote 0
Solution

Forum statistics

Threads
1,223,885
Messages
6,175,184
Members
452,615
Latest member
bogeys2birdies

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