goncalogera
New Member
- Joined
- Nov 10, 2020
- Messages
- 14
- Office Version
- 2019
- Platform
- Windows
- Mobile
- Web
Hi, I have a userform that needs to output the names of suppliers ("Fornecedores") and banks ("Banco") from a table in the respective combo boxes, FornecedorBox and BancoBox. For that I used the following loop and it has been working perfectly until I migrated the file from my personal computer to the company's computers... It throws the type mismatch error (Ive highlighted in the code the lines that throw an error) and I cant figure out where the error is. Ive tried putting the VAL() function but it just returns all zeros since they all throw an error.
VBA Code:
Private Sub UserForm_Initialize()
''''''' Fill-in IDbox '''''''
With ThisWorkbook.Sheets("Confirmings")
Me.IDBox.Value = .Range("A" & Rows.Count).End(xlUp).Value + 1
End With
''''''' Fill-in combo box with bank name from table ''''''
Dim i As Long
Dim n As Long
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Spreads")
n = sh.Range("A" & Application.Rows.Count).End(xlUp).Row
For i = 2 To n
With ThisWorkbook.Sheets("Spreads")
[B][U]Me.BancoBox.AddItem sh.Cells(i, 1)[/U][/B]
End With
Next i
''''''' Fill-in combo box with supplier name ''''''
Dim y As Long
Dim f As Long
Dim forn As Worksheet
Set forn = ThisWorkbook.Sheets("Fornecedores")
f = forn.Range("A" & Application.Rows.Count).End(xlUp).Row
For y = 2 To f
With ThisWorkbook.Sheets("Fornecedores")
[B][U] Me.FornecedorBox.AddItem forn.Cells(y, 1)[/U][/B]
End With
Next y
End Sub