Date formatting still causing me headaches

C

Corey

The code below fails to populate Listboxes 5-7 due to the date formating of
the sheet value and the Listbox4.
The sheet value ((myrow,4) is in a ddd dd mmm yy format, where the Listbox
keeps formatting to a mm/dd/yyyy.

I have tried to format the listbox4 before and after it is populated by:
ListBox4.Value = Format(.Cells(myrow, 4).Offset(, 3).Value , "dd/mm/yyyy")


But i still get NO result with the below due to a MATCH found but NOT
recognised at trhe highlighted line below.

Private Sub ListBox4_Click()
Application.ScreenUpdating = False
TextBox1.Value = ""
ListBox5.Clear
ListBox7.Clear
ListBox6.Clear
ListBox7.Clear
Dim LastCell As Long
Dim myrow As Long
LastCell = Worksheets("Data").Cells(Rows.Count, "D").End(xlUp).Row
With ActiveWorkbook.Worksheets("Data")
For myrow = 1 To LastCell
If .Cells(myrow, 4).Offset(, -3).Value <> "" And .Cells(myrow,
4).Offset(, -3).Value = ListBox1.Value And _
ListBox2.Value = .Cells(myrow, 4).Offset(, 3).Value And _
ListBox4.Value = .Cells(myrow, 4).Value Then ' <===== HERE

ListBox7.AddItem .Cells(myrow, 4).Offset(, 231).Value
ListBox5.AddItem .Cells(myrow, 4).Offset(, 230).Value
ListBox6.AddItem .Cells(myrow, 4).Offset(, 7).Value
End If

Next
End With
Sheets("Opening Page").Activate
Application.ScreenUpdating = True
End Sub


The code simply reducing possible senarios to ensure the correct row is
chaosen to be viewed in a sheet.
 
I

Incidental

Hi Corey

Not sure if this will help you could try putting the value in to the
listbox as .text rather than .value so that the listbox shows the date
as text rather than a date which would result in you having the
correct format that you could then change back into a date if you need
to. this may be a pain in the ass depending on how you are putting
the values into the listboxes but it may help

Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top