+ Reply to Thread
Results 1 to 3 of 3

Add A Row And Insert A Name Alphabetically In A Range

  1. #1
    Registered User
    Join Date
    03-19-2013
    Location
    Toronto,Canada
    MS-Off Ver
    Excel 2010
    Posts
    60

    Add A Row And Insert A Name Alphabetically In A Range

    Hello everybody,

    I use a Macro to add a row alphabetically in a spreadsheet (Archive) , based-on the name in the range ("F"). It is working well, however there are tow problems:
    1- the row is inserted alphabetically in tow steps. First, it inserts the row in the last empty row , then inserts it alphabetically when the next row is inserted.
    2- this macro works only through a command button in the same spreadsheet.

    What I want to do: 1- To insert the row alphabetically in one step only.
    2- I want to use this macro through a command button in another worksheet (Store).




    PHP Code: 
    Private Sub cmdbArchiveInsert_Click()
    Dim lngWriteRow As Long
    Dim ws2 
    As Worksheet
    Set ws2 
    Worksheets("Archive")
    lngWriteRow ws2.Cells(650001_
    .End(xlUp).Offset(10).Row
    If lngWriteRow 2 Then lngWriteRow 2
     
     Range
    ("A1:A65000").Select
     Range
    (SelectionSelection.End(xlDown)).Select
     Range
    (SelectionSelection.End(xlDown)).Select
     ActiveWindow
    .SmallScroll Down:=60
     ActiveWindow
    .ScrollRow 1
     Selection
    .Sort Key1:=Range("A2"), Order1:=xlAscendingHeader:=xlGuess_
     OrderCustom
    :=1MatchCase:=FalseOrientation:=xlTopToBottom_
     DataOption1
    :=xlSortNormal

        ws2
    .Range("A" lngWriteRow) = TxtLastName.Value
        ws2
    .Range("B" lngWriteRow) = txtbFirstName.Value
         ws2
    .Range("C" lngWriteRow) = TxtToday.Value
        ws2
    .Range("D" lngWriteRow) = TxtStore[PHP
    .Value
    ws2.Range("E" & lngWriteRow) = TxtPayer.Value
    ws2.Range("F" & lngWriteRow) = TxtFullName.Value
    ws2.Range("G" & lngWriteRow) = TxtJob.Value[/PHP]


    Thank you so much in advance

    Kiko

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Add A Row And Insert A Name Alphabetically In A Range

    attach please a sample file for testing
    If solved remember to mark Thread as solved

  3. #3
    Registered User
    Join Date
    03-19-2013
    Location
    Toronto,Canada
    MS-Off Ver
    Excel 2010
    Posts
    60

    Re: Add A Row And Insert A Name Alphabetically In A Range

    Thank you so much Patel45 for your reply. I have just fixed the problem

+ 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] Order / sort range by number in bracket first then remainder alphabetically.
    By skyping in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-25-2013, 08:14 AM
  2. Insert a row in a spreadsheet alphabetically
    By karimretina in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-24-2013, 01:33 PM
  3. add a row and insert a name alphabetically in a range
    By inno101 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 09-10-2012, 07:20 AM
  4. Help in Sorting Unknown Cell Range Alphabetically
    By crisshinn in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-21-2011, 07:01 AM
  5. Excel 2007 : Sort a dynamic range alphabetically
    By lmsexcelforum in forum Excel General
    Replies: 2
    Last Post: 01-26-2009, 11:42 AM

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