Excel/Excel-VBA

Advertisement


Question
How to expand selection of tables for connected worksheets while sorting in excel ?

   Sir, I have 2 worksheets with data table in both sheets. The only first column of table in in both worksheets are having names and are functionally linked and the worksheet 1 is the primary worksheet (That is if I edit/add a name in the worksheet 1, that will also reflect in worksheet 2) Now when I sort the table in worksheet 1 based on first coloumn, the excel asks whether the selection is to be expanded and when clicked "yes" the whole table will be sorted based on first coloumn. But as the name coloumn of worksheet 2 is functionally linked to worksheet 1 , it also gets sorted with out expanding selection to other coloumns of worksheet 2. Please suggest how to expand the selection to whole table in the worksheet 2 so that relative information in other coloumns also gets sorted based on the first coloumn.
 I am looking to sort the table based on ascending order of Name coloumn through VBA

Answer
Assuming the two tables are actually just one record, I would personally try to re-design the sheet in such a way that the data was not on two sheets - this would resolve the problem.  There is no sort event in VBA so you cannot run a macro prior to or post sort automatically, though you could have a macro that was invoked via a button or similar that sorted both sheets.  My own solution would be to have ALL the data in sheet 1, and formulas ONLY in sheet 2 that picked up whatever data was needed - this wouldn't be affected by re-sorting sheet1 as the formulas would still reflect the data.
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


Aidan Heritage

Expertise

I have provided first hand support since `95 for Microsoft Office majoring in Word and Excel - support for all versions from 2 onwards. I'm based in the UK, so please allow for time differences when asking me questions from other parts of the world!

Experience

My background is in the insurance industry and call centre areas, but have been called upon to provide many varied solutions.

Education/Credentials
I'm educated to UK A level standard, but as I left school some 30 years ago that is rather irrelevent - university of life has provided more of a background!

©2016 About.com. All rights reserved.