Link to home
Start Free TrialLog in
Avatar of Shanan212
Shanan212Flag for Canada

asked on

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: https://www.experts-exchange.com/questions/27383431/Extend-formulas-using-macro.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!
ASKER CERTIFIED SOLUTION
Avatar of Rory Archibald
Rory Archibald
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Shanan212

ASKER

Thanks that worked!