Results 1 to 9 of 9

Expand named range using VBA

Threaded View

ormerods Expand named range using VBA 09-13-2013, 10:41 AM
MarvinP Re: Expand named range using... 09-13-2013, 10:51 AM
ormerods Re: Expand named range using... 09-13-2013, 11:58 AM
Andy Pope Re: Expand named range using... 09-13-2013, 10:57 AM
ormerods Re: Expand named range using... 09-13-2013, 11:59 AM
Andy Pope Re: Expand named range using... 09-14-2013, 05:43 AM
ormerods Re: Expand named range using... 09-14-2013, 06:43 AM
Andy Pope Re: Expand named range using... 09-14-2013, 06:50 AM
ormerods Re: Expand named range using... 09-16-2013, 04:15 AM
  1. #1
    Registered User
    Join Date
    10-27-2011
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    88

    Expand named range using VBA

    I am trying to create a macro that will add a value to an existing named range, sort the name alphabetically and then expand the named range to include the new value.

    I have managed to get the data into the list, and sort the list alphabetically. The only part I am struggling with is expanding the named range. Can anybody help?
    Here is the code so far:

    Sub addfault()
    '
    ' addfault Macro
    '
    
    'copy new fault
        Sheets("Input").Select
        Range("F5").Select
        Application.CutCopyMode = False
        Selection.Copy
        
    'find column
        Sheets("Data").Select
        Cells.Find(What:=Sheets("Input").Range("D5").Value, After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate
        
    'move selection to bottom of column
        ActiveCell.End(xlDown).Offset(1, 0).Select
        
    'paste data
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
        
    'move selection to top of column
        ActiveCell.End(xlUp).Offset(1, 0).Select
        
    'select column
        Range(Selection, Selection.End(xlDown)).Select
        
    'sort a to z
    Dim oneRange As Range
    Dim aCell As Range
    
    Set oneRange = Selection
    Set aCell = ActiveCell
    
    oneRange.Sort Key1:=aCell, Order1:=xlAscending, Header:=xlGuess
    
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Expand named range across two separate columns
    By BlueScoob60 in forum Excel General
    Replies: 3
    Last Post: 09-04-2012, 02:50 AM
  2. cannot expand named range
    By Dreamwine59 in forum Excel General
    Replies: 1
    Last Post: 02-10-2009, 01:59 PM
  3. Cannot expand named range
    By Goatie in forum Excel General
    Replies: 1
    Last Post: 05-12-2008, 04:07 PM
  4. Cannot Expand Named Range - Help
    By Snig in forum Excel General
    Replies: 5
    Last Post: 08-03-2005, 01:05 PM
  5. [SOLVED] Cannot Expand Named Range - when size of the Range exceeds
    By Snig in forum Excel General
    Replies: 1
    Last Post: 07-07-2005, 09:05 AM

Tags for this Thread

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