V
veeraan
Hi,
I need help....
I have a worksheet which looks like this...
StoreNo---> 201 202 203
Week 1 X
Week 2 y
Week 3 z
I have two combobox's on main sheet where users can select Week's and Store
numbers.
So say I can select Week 1 and Store 201.
Once users have selected these two variables , they click on a button and
the corresponding data should be populated in a textbox . So when I click the
button , the output in textbox should be 'X' for above example.
I have the following code in button click event:
Dim strStoreNumber As String
Dim strAccountWeek As String
Dim rngLookup As Range
Dim varVlookupVarient As Variant
Private Sub CommandButton1_Click()
strStoreNumber = ComboBox1.Value
strAccountWeek = ComboBox2.Value
Set rngLookup =
Application.Workbooks("POS.xls").Worksheets("Sheet1").Range("AW")
' this doesnt work....
varVlookupVarient = Application.VLookup(strAccountWeek, rngLookup,
ComboBox1.Value, False)
' Below line works but I need the column in Vlookup to be dynamically
selected.....
'varVlookupVarient = Application.VLookup(strAccountWeek, rngLookup, 2, False)
MsgBox ("This is what you get" & varVlookupVarient)
' Once I get this data right, I can then have this as TextBox.value.
End Sub
Please help.....
I am not sure if I am doing this right...is there another way instead of
using Vlookups...
Regards
Veeraan
I need help....
I have a worksheet which looks like this...
StoreNo---> 201 202 203
Week 1 X
Week 2 y
Week 3 z
I have two combobox's on main sheet where users can select Week's and Store
numbers.
So say I can select Week 1 and Store 201.
Once users have selected these two variables , they click on a button and
the corresponding data should be populated in a textbox . So when I click the
button , the output in textbox should be 'X' for above example.
I have the following code in button click event:
Dim strStoreNumber As String
Dim strAccountWeek As String
Dim rngLookup As Range
Dim varVlookupVarient As Variant
Private Sub CommandButton1_Click()
strStoreNumber = ComboBox1.Value
strAccountWeek = ComboBox2.Value
Set rngLookup =
Application.Workbooks("POS.xls").Worksheets("Sheet1").Range("AW")
' this doesnt work....
varVlookupVarient = Application.VLookup(strAccountWeek, rngLookup,
ComboBox1.Value, False)
' Below line works but I need the column in Vlookup to be dynamically
selected.....
'varVlookupVarient = Application.VLookup(strAccountWeek, rngLookup, 2, False)
MsgBox ("This is what you get" & varVlookupVarient)
' Once I get this data right, I can then have this as TextBox.value.
End Sub
Please help.....
I am not sure if I am doing this right...is there another way instead of
using Vlookups...
Regards
Veeraan