Using VBA in place of an INDEX and MATCH statement.

4rcanine

New Member
Joined
Sep 2, 2014
Messages
25
Howdy Guys,

I've gotten myself stuck trying to improve a workbook I use while at work and am in dire need of help.

The workbook contains four worksheets, the first being a master list/table of information. The next three worksheets are the departments at my work and show the same information as the master however each worksheet only shows that departments information.
Previously the data was copied into each worksheet manually and I am trying to automate the process.

Initially I achieved this using the following INDEX and MATCH statement:
=IF(ISERROR(INDEX(MASTER!$A$2:$P$499,SMALL(IF((MASTER!$D$2:$D$499="1"),MATCH(ROW(MASTER!$B$2:$B$499),ROW(MASTER!$B$2:$B$499))),ROW(MASTER!G49)),COLUMN(MASTER!G49)))," ",INDEX(MASTER!$A$2:$P$499,SMALL(IF((MASTER!$D$2:$D$499="1"),MATCH(ROW(MASTER!$B$2:$B$499),ROW(MASTER!$B$2:$B$499))),ROW(MASTER!G49)),COLUMN(MASTER!G49)))

This formula is in cells A2:P150 on each department's worksheet. The department name is in column D, which is what it matches. This has worked fine until I've enconuntered the need to copy cell formatting along with the information (mainly cell shading/fill).

Is there a way this can be done within VBA, say each time a worksheet is opened?

Cheers!
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
I would record a macro in which you:
- Clear the dept worksheets
- For each dept:
- Filter the master table on the Dept
- Copy the visible rows to the associated dept sheet
 
Upvote 0

Forum statistics

Threads
1,222,383
Messages
6,165,665
Members
451,983
Latest member
Raph24

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top