+ Reply to Thread
Results 1 to 3 of 3

VBA - row insert in alphabetical order

  1. #1
    Registered User
    Join Date
    04-13-2013
    Location
    Wellington
    MS-Off Ver
    Excel 2003
    Posts
    5

    Question VBA - row insert in alphabetical order

    Hey Guys,

    I have need of some expert help now as I have been trying to modify code from others solutions and got absolutely no where for the last week.

    Sheet names:
    NEWSITE - this is where brand new entries are created (this is where I need the help)
    UPDATE - thanks to davesexcel for previous coding
    Data_Entry - this is where the data will be inserted

    So the process on the NEWSITE sheet is that you fill out the sitecode/BGP AS and QOS fields - this then allows a button to pop-up (Add Record), click the add record.
    the data is taken from the fields in NEWSITE and inserted into Data_Entry. At the moment this is selecting the next empty row.

    I need to change this as further processing in the rest of the sheets (that arent included in this version) have issues with vlookups and the insertion at the bottom of the sheet breaks them all. I dont really want the user touching Data_Entry sheet as that's raw data, so asking the user to go in, create a new row and then copy/paste into the right row... or doing sort on column A isn't an option.

    The VBA code is all done in each of the sheets so there are no modules used for reference.

    TIA
    Dribble
    Attached Files Attached Files
    Last edited by dribble; 11-19-2013 at 03:48 PM.

  2. #2
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: VBA - row insert in alphabetical order

    You don't necessarily have to recode.

    If the addition of rows/columns is throwing formulas off, there are a few workarounds.

    First, you could convert your Data_Entry to a table. Formulas that reference tables automatically adjust themselves as the tables grow in size.

    Also, you could use INDIRECT to target a static range.

    For example, Sum(a1:a10) throws an error if you delete rows A1:A10, but not if you used SUM(INDIRECT("A1:A10")) because the reference to A1:A10 within INDIRECT is read as text and then evaluated as a range, so it stands independantly from changes to the worksheet.

    Similarly VLOOKUP(a1,INDIRECT("A1:A5000"),2,0) can define your static range. You can even take it one step further and use formulas to auto-detect the number of non-blank rows and have that be your range.
    Last edited by daffodil11; 11-19-2013 at 04:05 PM.
    Make Mom proud: Add to my reputation if I helped out!

    Make the Moderators happy: Mark the Thread as Solved if your question was answered!

  3. #3
    Registered User
    Join Date
    04-13-2013
    Location
    Wellington
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: VBA - row insert in alphabetical order

    Thanks Daffodil11,

    i would be worried adjusting anything that is already referencing those cells, purely because this is being utilised like a RMDB not a real spread sheet function.
    My main issue with the ordering of this is that I have a "named" set of cells that I cant convert to an offset list as it breaks another formula. So anything that I come up with have to re-order the Data_Entry rows to alphabetical as the house of cards will come tumbling down...

    Cheers
    Dribble

+ 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. Macro To Insert Letters in Alphabetical Order ,
    By donnydorko in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-24-2009, 11:09 PM
  2. alphabetical order within a cell
    By David in forum Excel - New Users/Basics
    Replies: 5
    Last Post: 06-26-2006, 11:35 AM
  3. Alphabetical order possible? or not
    By OSSIE in forum Excel General
    Replies: 5
    Last Post: 06-22-2006, 02:25 PM
  4. How do I put worksheets in alphabetical order
    By Bob Phillips in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-06-2005, 06:05 PM
  5. Alphabetical Order
    By Jennifer_Taylor in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 01-27-2005, 10:49 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