selecting a range in a macro

mish78

New Member
Joined
Apr 27, 2009
Messages
12
Hi,
I am trying to select a range in a macro where the first cell position will be returned by a formula.

In excel =CELL("address",INDEX(E6:J6,1, MATCH(customer,E6:J6))) would give me $F$6 which is the location of the cell that has customer in it.

I am trying to use it in a macro but keep getting method range of object global failed. Is there any other way of selecting a range with the first cell value as a search.
e.g
Range("CELL('address',INDEX(E6:J6,1,MATCH(customer,E6:J6))):AA1000").Select

Thanks in advance
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
A couple of possibilities:

Code:
Sub Test1()
    Range(Evaluate("=CELL(""address"",INDEX(E6:J6,1, MATCH(customer,E6:J6)))") & ":AA1000").Select
    MsgBox Selection.Address
End Sub
 
Sub Test2()
    Range(Range("E6:J6").Cells(1, WorksheetFunction.Match(Range("customer"), Range("E6:J6"))).Address & ":AA1000").Select
    MsgBox Selection.Address
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,720
Messages
6,126,436
Members
449,314
Latest member
MrSabo83

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