Sending a range to function

Private Function FormulaFiller(idata As String, istart As String, iend As String)
    
    Dim rgCopy As Range, rgDelete As Range, rgFill As Range, rgClear as range
    
    Set rgCopy = ["istart"&:&"iend"]    'Formulas in these cells will be copied down
    Set rgFill = ["idata"]       'First piece of raw data

    set rgClear = range( ' need to clear the data/formula below istart and iend 
    Set rgFill = Range(rgFill, rgFill.Worksheet.Cells(Rows.Count, rgFill.Column).End(xlUp))  'All data in that column
    Set rgFill = rgCopy.Resize(rgFill.Rows.Count)       'Fill formulas down in this range
    
    Set rgDelete = rgCopy.Offset(1, 0).Resize(rgCopy.Worksheet.UsedRange.Rows.Count)
    rgDelete.ClearContents
    
    rgCopy.AutoFill rgFill, xlFillCopy
    Application.CutCopyMode = False

End Function

Open in new window



Hi,

I have the about function. However, I am getting an object not found error on these lines

    Set rgCopy = ["istart"&:&"iend"]    'Formulas in these cells will be copied down
    Set rgFill = ["idata"]       'First piece of raw data

    set rgClear = range( ' need to clear the data/formula below istart and iend

As you can see, I am getting a range from different function and trying to 'pull down' formulas. But I am having hard time bringing in ranges as string :/
If you see this thread, you will understand: http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/Q_27383431.html

I also need to clear the space below the initial formulas before those fields get populated. I started on a line but my solutions are not working/giving errors.

Any help is much appreciated!
Thanks!
LVL 13
Shanan212Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rory ArchibaldCommented:
Try using Evaluate:

Set rgCopy = Evaluate(istart & ":" & iend)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Shanan212Author Commented:
Thanks that worked!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.