add value to listbox from the date and name match each time

hsolanki

Board Regular
Joined
Jan 16, 2020
Messages
204
Office Version
  1. 2010
Platform
  1. Windows
Hi i have userform of which there is two textboxes of you enter the two between dates and combobox to select name from column H and user finds the matched date in Column against name in column H however it wont add any data to listbox to show all the data matched with the date between two dates searched with name. it is just loops and then ends the macro, can someone help me please

VBA Code:
 LastRow = s1.range("A" & Rows.Count).End(xlUp).Row
    For Each sh In s1.range("A5:A" & LastRow)
    
    
    If CLng(CDate(sh.Value)) >= CLng(CDate(tarih1)) And _
    CLng(CDate(sh.Value)) <= CLng(CDate(tarih2)) And _
    CStr(sh.Offset(0, 0).Value) = CStr(ComboBox1.Text) Then
    
ListBox1.AddItem
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Untested, I think this line:
VBA Code:
ListBox1.AddItem
should be
VBA Code:
ListBox1.AddItem sh
 
Upvote 0
Hi Akuini Thank you for your reply however your suggestion still hasn't work. is there any alternative way of doing also can listbox be added from multi sheets using the above search between 2 dates and name?
 
Upvote 0

Forum statistics

Threads
1,223,713
Messages
6,174,039
Members
452,542
Latest member
Bricklin

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