I am trying to determine if the cell of a listbox contains a specific extension. Here is what I am trying to use, but no dice:
If Listbox1.ListIndex >= 0 And Listbox1.Cell(Listbox1.LastIndex, 1) = folderItem.Name.Right(6) = “.pages” then
MsgBox “You have found all files that contain the “.pages” extension.”
End If
Any help would be greatly appreciated. Thanks in advance.
If Listbox1.ListIndex >= 0 And Listbox1.Cell(Listbox1.ListIndex, 1).Right(6) = ".pages" then
MsgBox "You have found all files that contain the ".pages" extension."
End If
Yeah I would not call it folderitem as thats bound to cause confusion
But is the line AS you wrote it ?
If Listbox1.ListIndex >= 0 And Listbox1.Cell(Listbox1.LastIndex, 1) = folderItem.Name.Right(6 ) = ".pages" then
If so then the second expression is the problem
If Listbox1.ListIndex >= 0 And Listbox1.Cell(Listbox1.LastIndex, 1) = folderItem.Name.Right(6 ) = ".pages" then
this is OK Listbox1.ListIndex >= 0
but Listbox1.Cell(Listbox1.LastIndex, 1) = folderItem.Name.Right(6 ) = ".pages"
isn’t (as for why not I could go into depth IF you want)
Maybe it should be
If Listbox1.ListIndex >= 0 And Listbox1.Cell(Listbox1.ListIndex, 1).Right(6 ) = ".pages" then
Thanks Alex and Norman. This did this trick. One other question for ya. Is there a way to automatically select all files that are dropped onto a listbox?