Computer Learning Zone CLZ Access Excel Word Windows

Our passion for learning, evident in the behaviour of every toddler, is the tool for our survival.

-Carl Sagan
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Excel Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Index and match in vba
Stanley Mc Keown 
     
2 years ago
I'm using index and match to find and return values inside a table which is inside a sheet ie not on it's own with column headings at the top ie the headings are down the sheet a bit hence the index and match to find the last date on two of the columns all of which works perfectly but ... when I try to put it into a loop macro to insert this index and match formula into thousands of similar sheets ( they're not all the same but all have the values in different places that I need to get ( which can be got with the index and match formula just copied and pasted into each sheet by hand )

The problem seems to happen because the formula has lost its references cos it's not in the sheet obviously.

Can anyone tell me if it is possible to insert this formula across thousands of workbooks using a vba macro or is there a better way to do it? ( I've managed to do it with a simple maths formula that just has straight cell ref like =E1+F1+G1 )
Alex Hedley  @Reply  
           
2 years ago
You'll be able to get the ref of the cell you're adding it to and calculate the relative cells to it.

Is it always the same i.e. column to right + etc?
Stanley Mc Keown OP  @Reply  
     
2 years ago
No -- that's the problem hence index and match to find the column then find the last value in that column ( which is a date )
Stanley Mc Keown OP  @Reply  
     
2 years ago
And the column starts halfway down the sheet
Stanley Mc Keown OP  @Reply  
     
2 years ago
Though if you mean the destination workbook and sheet -- I can specify which cell to put the formula in so that I can look it up from access.

That was my original plan
1 copy the formula to the sheet I need the info on.
2 formula finds the column and last value on it
3 I know exactly where the value is now so get it to access some method.

  There maybe some way the formula ( index and match which works no problem when it's anywhere in the sheet ) or a formula or code can be done directly from access.

I have a Loop macro to open each file in turn and paste into a cell -- only thing is I can't do it with that index and match formula. It's like excel is trying to resolve the formula even though I want to paste it as is.  ( ie it's inside quotation marks so you'd think it should see it as a string )
Stanley Mc Keown OP  @Reply  
     
2 years ago
I changed the cell references to absolute ie with $ signs in front and that works now when doing the job manually. Also I used a recorded macro ( while doing it manually ) which also works but only because both sheets are open and I get a load of warnings about circular references etc.
Stanley Mc Keown OP  @Reply  
     
2 years ago
I sorted the problem by taking the mountain to Mohammed ie copying the range involved on the data sheet (that's another problem I had to solve see below) to the "formula sheet" workbook with the formula already in a cell far enough to the right to be well clear of getting pasted over.

  I had trouble finding ( counting )  the number of columns cos the last column had a heading cell which was merged with 3 more columns to the right of it so it wouldn't see the last column and return a count which was one less than it should be.

  I solved that by creating temporarily a second sheet ( sheet 2 ) in the data workbook and pasting the values on sheet 1 with number formats only to sheet 2 then pasting that to the "formula sheet in the formula workbook.

  Now nested within the the loop macro I can suck out all the last dates along with any other relevant information about that record entry from every workbook in my trusted folder automatically. They all get saved along with a foreign key in a new record set ready to import to access.

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: 6/16/2026 1:41:59 PM. PLT: 1s