Object required

lynxbci

Board Regular
Joined
Sep 22, 2004
Messages
201
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hi,
I am trying to select a column range by first finding which column has the title I require (in this case "UseThis")
Then I want to select the range from that address (f.address) and offset it by a number of rows (in this case I am using 100)
The code works and msgBox shows $H$1 as expected from my data, as "UseThis" is in column H.
I then want to create a range $H$1:$H$100 for use later in a formula.

I get the 'Object Required Error (424)' when I try to set indexRange property.. what have I done wrong?

VBA Code:
Sub findIndex()

Dim indexRange As Range

'FINDS THE COLUMN TO USE AS A INDEX
With ActiveSheet.UsedRange

    Set f = .Find("UseThis", LookIn:=xlValues)
    
    If Not f Is Nothing Then
        MsgBox f.Address
        indexRange = f.Address.Offset(100, 0)
       
        
    End If

End With

End Sub
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
.address returns the string value of the address.

indexRange=f.offset(100,0) should do you.
 
Upvote 0
How about
VBA Code:
Set indexRange = f.Resize(100)
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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