Add Named Range Macro Code

  • Hi Forum,


    I think I have a syntax problem. I have workbook where users can generate and name new sheets through a macro. For each new sheet that is generated I add another row to a resume sheet where I need to present relevant data from each sheet in a seperat row. I have named the relevant cells in the sheet which I use as a template. When a user adds a new sheet through the macro a new row is generated which I would like to populate with data from the named cells/ranges of the new sheet in a way that automatically updates the resume whenever one of the other sheets are updated. I need to refer to the specific named range of the sheet on which I do not know the name, only the name variable.


    The task is pretty easy in normal Excel mode but I want to accomplish this proces with VBA.


    Regards.


    JOR

  • Re: Vba Syntax For Named Ranges


    This line should:

    Code
    Range("D" & LastRow + 1).FormulaR1C1 = Sheets(Navn) & "=Navn!RiskYear"


    should probably look like:

    Code
    Range("D" & LastRow + 1).FormulaR1C1 = "=" & Navn & "!RiskYear"



    ADDED BY ADMIN

    Code
    Sheet1.Range("A1:A10").Name="MyRange"

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!