XL07: Copy subset or named range into new range based on column values

JimTXL

New Member
Joined
Feb 5, 2009
Messages
1
Hello,

I have a spreadsheet that tracks stocks I'm interested in. The first 3 columns are (the rest of the columns being data such as P/E, Yield, etc.)

# Ticker Name
1 BAC Bank of America
1 WFC Wells Fargo
2 IBM IBM
2 ORCL Oracle
2 CSCO Cisco


The '#' is an arbitray grouping ID. 1 is for banking, 2 is for tech, etc. I have a named range, ValTable, that encompasses all the data in the table.

I would like to, in VBA/macro, loop through the ValTable range and copy a subset of the range, based on the # column, to a temporary range variable (let's call it TmpRange). I then want to take TmpRange and put a border around the data it contains in the worksheet using the "borderaround" method. Essentially:

  1. Copy all rows from range ValTable where # equals "1" to TmpRange.
  2. Put a border around the subset (or other formatting).
  3. Loop through the ValTable range to do the same for #'s 2, 3, etc.
I hope that explains it. This is my first post but I've been a huge fan of this board for years. :)

Regards,
Jim
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

Forum statistics

Threads
1,224,521
Messages
6,179,277
Members
452,902
Latest member
Knuddeluff

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