• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Automating and Emailing Pivot Table Reports (vlookup trouble shoot)|VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / Automating and Emailing Pivot Table Reports (vlookup trouble shoot)|VBA & Macros|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumVBA & MacrosAutomating and Emailing Pivot Table…
sp_PrintTopic sp_TopicIcon
Automating and Emailing Pivot Table Reports (vlookup trouble shoot)
Avatar
huy Dang

Active Member
Members
Level 0
Forum Posts: 4
Member Since:
October 12, 2020
sp_UserOfflineSmall Offline
1
October 12, 2020 - 9:59 am
sp_Permalink sp_Print

Hi There, 

Countinue to the topic of "Automating and Emailing Pivot Table Reports" and been post by Philip,

I did download the file excel and ths for sharing the excel file.

But I m having problem in step “Create an email and attach the PDF”. The fomular of Vlookup does not perform as usual. When I press Run the VBA , the fomular start to pick random email from database, not matching value. I did change fomular a lit bit and format data cell in number order (for easy matching) but problem is not solved. Could you help me out of this, I am appreciate your help
Below is fomular I am having trouble with. I also attach my file in this forum. 

.Display
.To = WorksheetFunction.VLookup(Range(“B1”).Value, Worksheets(“Managers”).Range(“Managers!A2:B15”), 2, True)

sp_AnswersTopicSeeAnswer See Answer
Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1514
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
2
October 12, 2020 - 10:48 am
sp_Permalink sp_Print

Hi Huy,

The issue is that VLOOKUP requires the lookup values to be sorted in ascending order.  The table you were using for lookup had the values in random order.

Sort the ma column in ascending order and it should all work fine.

regards

Phil

sp_AnswersTopicAnswer
Answers Post
Avatar
huy Dang

Active Member
Members
Level 0
Forum Posts: 4
Member Since:
October 12, 2020
sp_UserOfflineSmall Offline
3
October 12, 2020 - 12:43 pm
sp_Permalink sp_Print

Hi Philips, 

Ths for your excellent answer. I got the problem now. The Vlookup in VBA performs a bit different from excel it used to be.

Is it possible for vlookup to looking value in random order as my case? 

 

Best regards,

Huy Dang

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1514
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
4
October 12, 2020 - 2:39 pm
sp_Permalink sp_Print

Hi,

VLOOKUP will only work on data that is sorted.

If you have XLOOKUP you can use that on unsorted data though

WorksheetFunction.XLookup( Range("e3").Value, Worksheets("Managers").Range ("Managers[ma]"), Worksheets("Managers").Range( "Managers[Email]"))

Regards

Phil

Avatar
huy Dang

Active Member
Members
Level 0
Forum Posts: 4
Member Since:
October 12, 2020
sp_UserOfflineSmall Offline
5
October 12, 2020 - 4:28 pm
sp_Permalink sp_Print

Hi Philip

The code is works perfectly. Ths very much for your helping

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1514
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
6
October 12, 2020 - 4:52 pm
sp_Permalink sp_Print

You're welcome.

Avatar
huy Dang

Active Member
Members
Level 0
Forum Posts: 4
Member Since:
October 12, 2020
sp_UserOfflineSmall Offline
7
January 15, 2021 - 4:53 pm
sp_Permalink sp_Print

HI Philip

 

My runing VBA show code erro of 1004 , which I have no idea of what went wrong with my formula. Could you take a look at my formula. 

 

Ths Philip

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Mynda Treacy, Shanna Henseler, Stacy Culpepper
Guest(s) 10
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 870
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
A.Maurizio: 202
Jessica Stewart: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
John Chisholm
vexokeb sdfg
John Jack
Malcolm Toy
Ray-Yu Yang
George Shihadeh
Naomi Rumble
Uwe von Gostomski
Jonathan Jones
drsven
Forum Stats:
Groups: 3
Forums: 24
Topics: 6212
Posts: 27237

 

Member Stats:
Guest Posters: 49
Members: 31889
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.