userform vlookup row criteria

codechris

New Member
Joined
Sep 8, 2021
Messages
1
Office Version
  1. 2010
Platform
  1. Windows
Hi,

I have this problem, i have a userform where u can chose diffrent kind of hardware equipment, when selected it goes to one sheet, after that i want it to go to another sheet and in a specific row give me number "1"
See my code so far:

In code below the numer "1" goes direct to assigend cell : Blad2.Range("M98") ( but i want the number to go to the same row as a specific criteria.

The criteria is in column A (it is the distributers order number) i want excel to find that and but my numer in column M on the same row.

Thanks for your help :)


Private Sub CommandButton1_Click()




'For listbox to worksheet

Dim r As Long





For r = 1 To Me.lbxHW.ListCount - 1

If Me.lbxHW.Selected(r) Then

Blad28.Range("A" & Rows.count).End(xlUp).Offset(1, 0) = Me.lbxHW.List(r, 0)



For i = 2 To 20


If Blad28.Cells(i, 1) = "HP 700 Printer & Inks" Then

Blad2.Range("M98") = Application.WorksheetFunction.CountIf(Blad28.Range("A:A"), "HP 700 Printer & Inks")
Blad2.Range("M737") = Application.WorksheetFunction.CountIf(Blad28.Range("A:A"), "HP 700 Printer & Inks")
Blad2.Range("M739") = Application.WorksheetFunction.CountIf(Blad28.Range("A:A"), "HP 700 Printer & Inks")
Blad2.Range("M740") = Application.WorksheetFunction.CountIf(Blad28.Range("A:A"), "HP 700 Printer & Inks")
Blad2.Range("M741") = Application.WorksheetFunction.CountIf(Blad28.Range("A:A"), "HP 700 Printer & Inks")
Blad2.Range("M742") = Application.WorksheetFunction.CountIf(Blad28.Range("A:A"), "HP 700 Printer & Inks")
Blad2.Range("M743") = Application.WorksheetFunction.CountIf(Blad28.Range("A:A"), "HP 700 Printer & Inks")
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Forum statistics

Threads
1,213,539
Messages
6,114,221
Members
448,554
Latest member
Gleisner2

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