• 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
You are here: Home
Lost password?
sp_Search
Advanced Search
Advanced Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search

Please confirm you want to mark all posts read

Mark all topics read

sp_MobileMenu Actions
Actions
sp_LogInOut
Log In
sp_Search

Search Forums

sp_RankInfo
Ranks Information
Avatar

New/Updated Topics

General Excel Questions & Answers

  removing pesky hidden xml sheets in a workbook

  Sick leave periods in one cell

  Data Validation with unique values

  Amortization

Dashboards & Charts

  Connecting 2 separate pivot charts or data sets to calculate…

VBA & Macros

  Send Email Code Error

Power Query

  How to add a new query for each cell of a column

  Source doesn't exist for Power Query folder

  Create list of working days

  Power Query - How to add multiple columns from parent to Nes…

  Unpivoting data to merge rows

Xtreme Pivot Tables

  Pivot Tables - Grand Totals AND Summary Percentages in the s…

Power BI

  How identify the URL to connect power bi with Project online

Excel Expert

  new and deleted entries

  Excel Dashboard

Select Forum

  Rules and Guides

Forum Rules and Guides

  Public Forums - For Registered Users

General Excel Questions & Answers

Dashboards & Charts

VBA & Macros

Power Query

Power Pivot

  Course Members Only

Excel Dashboards

Power Query

Power Pivot

Xtreme Pivot Tables

Excel for Decision Making

Excel for Finance

Power BI

Excel

Word

Outlook

Excel Expert

Excel for Customer Service Professionals

Excel Analysis Toolpak

Excel Tables

Excel for Operations Management

Financial Modelling

Advanced Excel Formulas

Pivot Tables Quick Start

ForumsVBA & Macros
sp_TopicIcon
Vlookup for filtered data in VBA
Avatar
Arunachal Jois
Posts: 17
Level 0
August 3, 2020 - 3:58 pm

1

Hello everyone
I need help for how to perform Vlookup for filtered data in VBA 

Avatar
Philip Treacy
Posts: 1514
Level 10
August 3, 2020 - 4:08 pm

2

Hi,

If data is filtered, for example in a table, VLOOKUP still returns the same data.  Filtering has no effect.

Maybe if you explain what you are trying to do we can find a solution.  Please supply a workbook with data and clear explanations of what you want and the expected result.

Thanks

Phil

Avatar
Arunachal Jois
Posts: 17
Level 0
August 3, 2020 - 7:46 pm

3

I have some data in col Z. If i found "Error" in col Z then i want to do vlookup in AA. If there is no "Error" in col Z then i dont want to Vlookup it in column AA.

Now i'm stuck in the below code

If WorksheetFunction.CountIf(Range("Z:Z"), "Error") > 0 Then
With Sheets("PIR Template")
With .Range("A1:AH1")
.AutoFilter
.AutoFilter Field:=26, Criteria1:="Error"
End With

Range("AA" & cell.Row).Select.Formula = "=VLOOKUP(RC[-2],ZLOE019!C1:C7,7,0)"

End With

Avatar
Philip Treacy
Posts: 1514
Level 10
August 3, 2020 - 10:04 pm

4

Philip Treacy said

Please supply a workbook with data and clear explanations of what you want and the expected result.

Thanks

Phil  

I can't help without your workbook.

How exactly are you stuck?

Avatar
Arunachal Jois
Posts: 17
Level 0
August 3, 2020 - 10:54 pm

5

i will provide you the workbook with macro file

Simply saying i want to Vlookup a filtered data only for visible cell

I provided the information in Macro file and i also facing my macro button "Validation" not working properly
Could you please help on that also ? 

Avatar
Philip Treacy
Posts: 1514
Level 10
August 5, 2020 - 9:36 am

6

Hi,

When the Validation sub runs you have these 3 lines of code at the top

   LR = Range("U" & Rows.Count).End(xlUp).Row
   LR1 = Range("B" & Rows.Count).End(xlUp).Row
   LR2 = Range("B" & Rows.Count).End(xlUp).Row

But these are acting on the active sheet which is FORM therefore they are all set to 1.

LR1 and LR2 are set to correct values later in your code, after you switch to other sheets.  But LR is not set to any other value so the code that relies on it is not working properly.

At the top of the validation sub, activate the sheet you want before setting values for LR, LR1 and LR2.

Regards

Phil

Avatar
Arunachal Jois
Posts: 17
Level 0
August 5, 2020 - 5:20 pm

7

Thanks for the solution
But i don't know how to do that
Can you make changes and send the revised file for me if possible ?

Avatar
Philip Treacy
Posts: 1514
Level 10
August 5, 2020 - 5:56 pm

8

Hi,

I'm a bit confused.  I don't know what sheet you want the code to act upon.

All you need is a line like this

  Sheets("PIR Template").Activate

before the 3 lines that set values for LR, LR1 an LR2. 

I'm guessing that's the sheet you want but as I said, I don't know for sure.  How can I know? You need to tell me what sheet you want the code to work with.

Regards

Phil

Avatar
Arunachal Jois
Posts: 17
Level 0
August 5, 2020 - 6:24 pm

9

did you tried to run macro like that ?
Is it working fine ?

Avatar
Philip Treacy
Posts: 1514
Level 10
August 5, 2020 - 7:22 pm

10

Seems to be, but again, you haven't clearly explained the problem or desired result to I'm guessing.  Have you tried it?

Avatar
Arunachal Jois
Posts: 17
Level 0
August 5, 2020 - 8:16 pm

11

Yes i tried it
Now it is working fine for me
Thanks for the support
I have one more question - in last i put VLookup
But i need vlookup for visible cells only. Can you please tell me to put Vlookup for visible cells only in col AA

Avatar
Philip Treacy
Posts: 1514
Level 10
August 5, 2020 - 8:24 pm

12

The code does enter a VLOOKUP only for visible cells in AA.

If you are getting some other result please attach the workbook again so I can see what's happening.

Avatar
Arunachal Jois
Posts: 17
Level 0
August 5, 2020 - 8:45 pm

13

Okay will finish all the code today or tomorrow 
If any issues will contact you here again
Thank you so much again for your support Philip

Avatar
Philip Treacy
Posts: 1514
Level 10
August 5, 2020 - 10:37 pm

14

You're welcome

Forum Timezone:
Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Andy Kirby, MohamedGadAllah, Jeff Krueger, RAMEZ ATTAR, Kylara Papenfuss
Guest(s) 10
Currently Browsing this Page:
1 Guest(s)

Devices in use: Desktop (8), Phone (7)

Forum Stats:
Groups: 3
Forums: 24
Topics: 6212
Posts: 27236
Member Stats:
Guest Posters: 49
Members: 31889
Moderators: 3
Admins: 4
© Simple:Press

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.