+ Reply to Thread
Results 1 to 9 of 9

Adding row to a named range-updating the named range address

Hybrid View

kjsconv Adding row to a named... 07-30-2013, 08:50 AM
apo Re: Adding row to a named... 07-30-2013, 09:33 AM
kjsconv Re: Adding row to a named... 07-30-2013, 10:24 AM
kjsconv Re: Adding row to a named... 08-07-2013, 07:16 AM
kjsconv Re: Adding row to a named... 07-30-2013, 10:11 AM
apo Re: Adding row to a named... 07-30-2013, 10:48 AM
kjsconv Re: Adding row to a named... 08-12-2013, 11:22 PM
apo Re: Adding row to a named... 08-07-2013, 07:25 AM
kjsconv Re: Adding row to a named... 08-07-2013, 10:57 AM
  1. #1
    Registered User
    Join Date
    12-30-2012
    Location
    Nacogdoches, Tx
    MS-Off Ver
    Excel 2015
    Posts
    65

    Adding row to a named range-updating the named range address

    I have a file to keep records of RV park guest.
    I use a row of data range named GuestIP where I enter the data for each new guest.

    I then use the following commands to add the guest to range named Guest_DB.
    Sheets("Guest-DB").Range("GuestIP").Copy
        Sheets("Guest-DB").Range("C" & Rows.Count).End(xlUp).Offset(1).PasteSpecial xlPasteValues
        Sheets("Guest-DB").Range("c" & Rows.Count).End(xlUp).PasteSpecial xlPasteFormats
    However this does not change the address of the Guest-DB to include the added guest.

    ie Before adding the new guest the Guest-DB address is C6:AB564, after updating the address is still C6:AB564 needs to be C6:AB565.

    vlookup commands else where in the workbook cannot find the new guest until I manually change the Address to include the row with the new guest.

    Is there a way to change the range address when you add a row to the bottom of the range?

    Any help would be appreciated.

  2. #2
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: Adding row to a named range-updating the named range address

    Hi..

    I then use the following commands to add the guest to range named Guest_DB.
    Your sheet is named "Guest_DB".. so i assume that that is a 'typo'... and therefore assume your Named Range is called "GuestIP"?

    Here's a way you can increase the size(by 1 row) of your Named Range...

    ActiveWorkbook.Names.Add Name:="GuestIP", RefersToR1C1:= _
                .Range("GuestIP").Offset(1, 0)

    It basically 're-adds' your named range and increases the row size by 1...
    Does that make sense?

  3. #3
    Registered User
    Join Date
    12-30-2012
    Location
    Nacogdoches, Tx
    MS-Off Ver
    Excel 2015
    Posts
    65

    Re: Adding row to a named range-updating the named range address

    Ok, I tried that line as a stand alone to see what it did. I had to add sheets id in front of the .range to make it work. but that would solve my problems

    Thank You very much
    JWD

  4. #4
    Registered User
    Join Date
    12-30-2012
    Location
    Nacogdoches, Tx
    MS-Off Ver
    Excel 2015
    Posts
    65

    Re: Adding row to a named range-updating the named range address

    I used this script and it appeared to work.
    However after several entries I discovered the Range address as not 'Adding' the new line it was shifting the Range name down by one line.
    In a different file the Range name "ProLst" starts in cell B2 and ends in cell K79,
    When I use the following commands:
    '==============
    Sheets("Formulas").Range("NuItem").Copy
    Sheets("Lkups").Range("B" & Rows.Count).End(xlUp).Offset(1).PasteSpecial xlPasteValues  'Adding to Range - ProLst cells B2 thru K79
    Sheets("Lkups").Range("b" & Rows.Count).End(xlUp).PasteSpecial xlPasteFormats
    '------------------Re ID Ranges Names----------------
    Sheets("Lkups").Select
    Range("B2").Select
    ActiveWorkbook.Names.Add Name:="ProLst", RefersToR1C1:= _
                Sheets("Lkups").Range("ProLst").Offset(1, 0)              ' Renaming range ProLst to be cells B2 thru K80
    '--------
    to add a new item to the list, the new range for 'ProLst' is now B3 thru K80, not the intended B2 thru K80.
    I lose the first row of data in the file.

    I need the range name to increase by one row of data, not just change the location of the range.

    Any help would be appreciated.
    Thank you

  5. #5
    Registered User
    Join Date
    12-30-2012
    Location
    Nacogdoches, Tx
    MS-Off Ver
    Excel 2015
    Posts
    65

    Re: Adding row to a named range-updating the named range address

    Not sure if that's what I'm looking for.

    The Name "Guest-DB" was an error.
    The worksheet sheet name is "Guest-DB", but
    The range I want it to add to is located on worksheet "Guest-DB" range name is "GuestData".


    GuestIP is a single row where I manually enter some of the information, other parts of the row calculate information. Once the information has been verified I add the values to the "GuestData" range.

    I don't want the calculation "formulas" from the input range "GuestIP" in the output range "GuestData",
    just the values.
    I want each record in that, ("GuestData"), range unchanged after it's been added.

    vlookup formulas else where in the workbook look up "GuestData" for information about a guest.

    If the line you show just changed "GuestData" by one line and that all it does, I could use it.

    Thank you
    JWD

  6. #6
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: Adding row to a named range-updating the named range address

    Hi.. yeap .. sorry.. that line of code would normally be used like:

    
    With Sheets("SheetID")
    ActiveWorkbook.Names.Add Name:="GuestIP", RefersToR1C1:= _
                .Range("GuestIP").Offset(1, 0)
    
    End With

  7. #7
    Registered User
    Join Date
    12-30-2012
    Location
    Nacogdoches, Tx
    MS-Off Ver
    Excel 2015
    Posts
    65

    Re: Adding row to a named range-updating the named range address

    Change my code and this one worked
    Thank You

  8. #8
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: Adding row to a named range-updating the named range address

    Hi..

    Oops..
    I may have led you astray previously..

    This will increase the range by 1 row..

    With Worksheets("Lkups")
            ActiveWorkbook.Names.Add Name:="ProLst", RefersToR1C1:= _
            .Range("ProLst", .Range("ProLst").Offset(1, 0))
               
    End With

  9. #9
    Registered User
    Join Date
    12-30-2012
    Location
    Nacogdoches, Tx
    MS-Off Ver
    Excel 2015
    Posts
    65

    Re: Adding row to a named range-updating the named range address

    Thank You, I'll try it today.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Use address of named range to find same address in another worksheet
    By dwsteyl in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-08-2013, 04:56 PM
  2. [SOLVED] Determine what Named Range the Target Address is and return Named Range Name
    By jordan2322 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-18-2012, 10:49 PM
  3. returning the address of a named range in VBA
    By zinny in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-22-2008, 05:18 AM
  4. getting the absolute range address from a dynamic named range
    By junoon in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-21-2006, 09:30 AM
  5. [SOLVED] Updating a named range
    By joala in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-16-2006, 02:15 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1