Why not keep account combo as a single column & reference that along with the vendor combo, it keeps things a lot simpler.
Sorry I should have clarified. I didn't want to over complicate my explanation so I just used 2 columns to explain what I need, I now realize that actually just over complicated it.
what actually is happening is we are breaking up the accounts for every analyst in the team - so that the only accounts they have access to is the one assigned to them.
Since one account number can exist more than once across different vendors, the only way to identify the correct row is by using Vendor and Account at the same time. So:
Account: 001 and Vendor: 1 & Account: 001 and Vendor:2 can actually belong to different analysts.
Every analysts will have a copy of this excel sheet which is pulling (by data query) data from a masterfile we have on our sharedrive.
this is what I have right now:
Code:
Option Explicit
Dim DICT As Object
End Sub
Private Sub UserForm_Initialize()
Dim Analyst As String
Analyst = Sheets("Function_Reference").Range("b11")
[COLOR=#008000]'Get Analyst Name, from a hidden reference sheet.[/COLOR]
Dim KEY As Variant
Set DICT = CreateObject("Scripting.dictionary")
For Each KEY In [Accounts].Columns(4).Rows
[COLOR=#008000]'The analyst name is in column 4, so I adjusted the offset accordingly.[/COLOR]
If Not DICT.Exists(KEY.Value) Then
Set DICT(KEY.Value) = CreateObject("scripting.dictionary")
End If
DICT(KEY.Value)(KEY.Offset(, -3).Value) = ""
Next KEY
Me.ComboBox1.List = DICT(Analyst).Keys
[COLOR=#008000]'Load the userform with the correct list immedietly. There's no actual need to modify it while using the list since the analyst name is already defined.[/COLOR]
End Sub
So what's happening is, Combobox1
(or AccountBox in my form) is using 2 columns.
then when completing the userform is complete with a button press I just get the information with
Code:
[COLOR=#574123][Invoices].Rows(x).Columns(c) = Me.ComboBox1.value[/COLOR]
[COLOR=#574123][Invoices].Rows(x).Columns(c+1) = Me.ComboBox1.column(1) [/COLOR]
I do it like that in case an analyst has a duplicate account number but with two separate vendors.
I ofcourse have other input boxes and such in the form and therefore other macros, but non of those are relevant to this issue.
sorry for not clarifying, I was hoping I would be able to break down and learn whatever I got from here and figure it out myself.
the macro is almost perfect, I just need it to have the 2 columns and its just what I am looking for.