PDA

View Full Version : Help with a couple lines of code please...



lbartowski
06-27-2010, 08:44 AM
Take a look .

lbartowski
06-27-2010, 09:13 AM
Any advice is appreciated.

shrivallabha
06-27-2010, 09:45 AM
In the simplest case:

Private Sub cmdOK_Click()

With Sheets("Components")
For i = 2 To 8
If .Cells(i, 1).Value = ComboBox1.Value Then
lblstandard.Caption = "Standard Qty.: " & .Cells(i, 1).Offset(, 1).Value
GoTo Deluxe:
End If
Next i
Deluxe:
For i = 13 To 19
If .Cells(i, 1).Value = ComboBox1.Value Then
lbldeluxe.Caption = "Deluxe Qty.: " & .Cells(i, 1).Offset(, 1).Value
End If
Next i
End With
End Sub

lbartowski
06-27-2010, 09:51 AM
Thanks. That's the simplest form? I was trying to stick with using the find or vlookup functions though.

lbartowski
06-27-2010, 10:43 AM
Thanks for the help.

mdmackillop
06-27-2010, 11:09 AM
As this appears to be homework, our rules don't allow answers to be provided
For guidance:
"Find" is the correct approach.
Check the property that allows data to be added to a label. You need to refer to this.
You are looking to find "combobox1", There is not a part with this name.
Your code can be written on one line, unless there is another use for the variable vStandardOut.
Always use Option Explicit.

Aussiebear
06-27-2010, 02:11 PM
It seems that since your comment Malcolm, the Op has come in and deleted an entire post and destroyed the context of the thread. I wonder why they felt the need to do that?

mdmackillop
06-27-2010, 02:20 PM
Banned for 7 days for unwarranted deletions and lack of response.

shrivallabha
06-27-2010, 11:05 PM
Twice I have fallen into these things. This probably seems to be the easiest (and the worst) way to complete educational assignments.

Next time I will look out. For once, I had inkling of doubt as it was named '6th week's assignment' but was not sure.