You are here:

Excel/index and match issue

Advertisement


Question
QUESTION: Hi Tom

Consider this:  I have a worksheet (A) that picks up information from worksheet (B).  The method that I use to collect this information is index and match.  I receive worksheet (B) every six weeks.  All of the headings remain the same except one i.e the period of the year.

The first version of wroksheet (B) will contain a column heading "AUT1"  (Autumn one scores)  Worksheet (A) will pick up these scores and put them in the appropriate place.  When I receive the next version of worksheet (B) there will be a new column, "AUT2".  Unfortunately the column heading "AUT1" will have been removed.

Worksheet (A) will then lose information for "AUT1"  but have it for "AUT2".  Is there any way around this?

Chris Mitchell

ANSWER: Christopher Mitchell,

before you change worksheet B, in worksheet A, select the column, Do a copy, then do a paste special values (paste values in the paste dropdown in excel 2007 and later).  This will replace the formulas with the values they return.  

Now when worksheet B changes, worksheet A will still retain the old values.

--
Regards,
Tom Ogilvy


---------- FOLLOW-UP ----------

QUESTION: Hi Tom

Thank you for the prompt response.  I had considered this approach but was hoping to achieve the same response with a macro because on occasion others might be handling the file and I wanted to cut down the chance of human error as much as possible.  

Your thoughts?

Chris Mitchell

Answer
Chris Mitchell,

with so little specific information, best I can do is show you some sample code.  If I wanted to replaced formulas in the range D2:D300 on Sheet1 with the values they produced then I would use the below code snippet.  

with worksheets("Sheet1").Range("D2:D300")
 .formula = .value
End with

This will achieve the same as paste values.

Change the sheetname and range reference to address the actual location on your sheet and of course the snippet would have to be placed in a macro such as

Sub LockValuesAut1()
with worksheets("Sheet1").Range("D2:D300")
 .formula = .value
End with
End Sub

so the user would execute the macro LockValuesAut1

--
Regards,
Tom Ogilvy

About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here

Excel

All Answers


Answers by Expert:


Ask Experts

Volunteer


Tom Ogilvy

Expertise

Selected as an Excel MVP by Microsoft since 1999. Answering Excel questions in Allexperts since its inception in 2001. Able to answer questions on almost all aspects of Excel's internal capabilities. If seeking a VBA solution, please specify that in your question itself so I give you the answer you want. [Excel has weak protection - if you are distributing an application, I don't answer questions on how to protect your project from your users.]

Experience

Extensive experience.

Education/Credentials
Master of Science (MS) degree Operations Research (ORSA)

Awards and Honors
Microsoft MVP in Excel.

©2016 About.com. All rights reserved.