Select cells based on named Range and a column heading

G

Guest

Friends,

I have a spreadsheet similar to the following:

A B C
1 Symbol Quant PnL
2 DELL 50
3 INTC 100
4 AMD 200

I have a named Range "Symbol" for cells A2..A4.

I want to select cells C2..C4 using the fact that they are in the column
with the heading of "PnL" and that they correspond to the Range "Symbol".

In other words, I want the code to say, "Select the cells that correspond to
the Range "Symbol" but are in the column with the heading "PnL".

Thanks,
Alan
 
V

Vasant Nanavati

Range("Symbol").Offset(,
WorksheetFunction.Match("PnL",Range("A1:Z1"),0)-1).Select
 
G

Guest

Assuming your headings are in row 1 then try:

Dim fndCell As Range
With Rows(1)
Set fndCell = .Find("Pnl")
If Not fndCell Is Nothing Then
Range("Symbol").Offset(0, fndCell.Column - _
Range("Symbol").Column).Select
End If
End With

Hope this helps
Rowan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top