Computer Learning Zone CLZ Access Excel Word Windows

If you are planning for a year, sow rice; if you are planning for a decade, plant trees; if you are planning for a lifetime, educate people

-Chinese Proverb
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Excel Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Need Help with Xlookup in VBA
Mark Hache 
    
2 months ago
I'm concantinating two values from an Excel table (date(m/dd/yyyy) & time (h:mm AM/PM) and trying to find a matching value on another sheet in a column that already has the concantenated values (m/dd/yyyy h:mm AM/Pm), using the formula as follows:
=XLOOKUP($T$20+T23, Appointments!$E$1:$E$1000, Appointments!$D$1:$D$1000,"")
It can't find a match even though I know there is one there.
Richard Rost  @Reply  
          
2 months ago
If T20 is a real date and T23 is a real time, adding them together is exactly how you build a proper datetime in Excel. The issue is usually that one side of the comparison is a true numeric date/time value and the other side is text that just looks like a date and time because of formatting.

I'd check with ISNUMBER and ISTEXT on both the lookup value and the values in the Appointments column. If either one is text, you'll need to coerce it or rebuild it as a true date/time value. Also make sure there aren't hidden seconds in one value that aren't showing in the formatted display. That alone can make two values look identical but not actually match.
Mark Hache OP  @Reply  
    
2 months ago
So, I got the same formula working while in the Excel table but just can't get to work inside of VBA (using Application.WorksheetFuntion.Xlookup). I've changed all the data types to match, created a Helper column in another tab to compare the concantenated value to but Excel keeps sneaking in "ss" to time value which is formatted only for "h:mm". I suspect this where it can't find a match. At my wit's end and don't know what to do next. I'm going to have to brute force it using FOR...IF...THEN...ELSE...NEXT loops to find the appropriate value. No finesse in this.
Richard Rost  @Reply  
          
2 months ago
Can you post a screen shot?
Mark Hache OP  @Reply  
    
2 months ago

Mark Hache OP  @Reply  
    
2 months ago
Of interest, when I'm looking up a specific value in a single cell and I represent it as ws.Range("E25").Text the following formula works:
result = Application.WorksheetFunction.XLookup(lookupValue, ws.Range("E25").Text, returnRange, "N/A") ' This works!!
Mark Hache OP  @Reply  
    
2 months ago
My last post led to a BREAK THROUGH! Once I converted the Helper column to text (=TEXT(A13,"m/dd/yyyy")&" "&TEXT(B13,"h:mm am/pm")), the lookup worked!. I didn't need to specify a specific cell, rather the lookup range became what I set it at (Set lookupRange = ws.Range("E:E")). Frustrated no more!
Richard Rost  @Reply  
          
2 months ago
Awesome. Glad you figured it out. Doesn't that feel fantastic? I love that sensation. :)

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Excel Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/9/2026 7:35:03 AM. PLT: 1s