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

hsolanki

Board Regular
Joined
Jan 16, 2020
Messages
124
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
 

Some videos you may like

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

Akuini

Well-known Member
Joined
Feb 1, 2016
Messages
2,963
Office Version
  1. 365
Platform
  1. Windows
Untested, I think this line:
VBA Code:
ListBox1.AddItem
should be
VBA Code:
ListBox1.AddItem sh
 

hsolanki

Board Regular
Joined
Jan 16, 2020
Messages
124
Office Version
  1. 2010
Platform
  1. Windows
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?
 

Watch MrExcel Video

Forum statistics

Threads
1,127,888
Messages
5,627,474
Members
416,250
Latest member
darius_rebelo

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
Top