Results 1 to 9 of 9

Alphanummerical aligning of numbers (addition to previous tread)

Threaded View

  1. #1
    Registered User
    Join Date
    08-25-2011
    Location
    Denmark
    MS-Off Ver
    Excel 2010
    Posts
    8

    Alphanummerical aligning of numbers (addition to previous tread)

    Hi guys,
    This tread is in addition to a previously which you guys solved for me (http://www.excelforum.com/excel-gene...nsolidate.html)
    To summerize the previous tread, i'm dealing with a large amount of data in excel, which every month has to be aligned with the (numerical) account numbers from our ERP-system.

    So my new headache is that we want to expand the Datawarehouse so it is able to contain alphanumerical account numbers (numbers and letters), which complicates the macro. Previously the macro perfectly aligned the account numbers in nummerical order. But when we add letters to this, it puts the alphanummerical numbers at the end of the macro. I want to numbers to primary determine the order, and letting the letters be the secoundary determinant.

    Current situation (with alphanummerical numbers):
    100 100 597,5359479
    200 200 184,4143015
    1000
    2100 2100 690,3195229
    4210
    100-BB
    100-CC 600,6907594
    100-DD 100-DD 25,86463684
    100-AA 100-AA 959,2499921
    200-AA 404,4266519
    200-CC
    200-AA

    Where row 1 and 2 is being aligned and row 3 is random numbers following row 2.
    Seems like this letter formating is random (since BB is above AA)

    Correct formating:
    100 100 597,5359479
    100-AA 100-AA 959,2499921
    100-BB
    100-CC 600,6907594
    100-DD 100-DD 25,86463684
    200 200 184,4143015
    200-AA 200-AA 404,4266519
    200-CC
    1000
    2100 2100 690,3195229
    4210

    Please have a look at the attached excel file (the above is a bit blurry)

    Below you see the macro made by stanleydgromjr (which works perfect without alphanummerical numbers)

    Sub AlignAccountNbr()
    ' stanleydgromjr, 08/25/2011
    ' http://www.excelforum.com/excel-gene...nsolidate.html
    Dim LR As Long, a As Long
    Dim AccountNbr As Range
    'Application.ScreenUpdating = False'
    Worksheets("Macro").Activate
    LR = Range("A" & Rows.Count).End(xlUp).Row
    Range("A4:B" & LR).Sort Key1:=Range("A4"), Order1:=1, Header:=xlNo
    LR = Range("C" & Rows.Count).End(xlUp).Row
    Range("C4:D" & LR).Sort Key1:=Range("C4"), Order1:=1, Header:=xlNo
    LR = Range("A" & Rows.Count).End(xlUp).Row
    Set AccountNbr = Range("A1:B" & LR)
    a = 4
    Do While AccountNbr.Cells(a, 1) <> ""
      If AccountNbr.Cells(a, 1).Offset(, 2) <> "" Then
        If AccountNbr.Cells(a, 1) < AccountNbr.Cells(a, 1).Offset(, 2) Then
          AccountNbr.Cells(a, 1).Offset(, 2).Resize(, 2).Insert -4121
        ElseIf AccountNbr.Cells(a, 1) > AccountNbr.Cells(a, 1).Offset(, 2) Then
          AccountNbr.Cells(a, 1).Resize(, 2).Insert -4121
          LR = LR + 1
          Set AccountNbr = Range("A1:B" & LR)
        End If
      End If
      a = a + 1
    Loop
    Application.ScreenUpdating = True
    End Sub
    I really hope you are able to help me with this, Thanks in advance!
    Attached Files Attached Files
    Last edited by Richard Buttrey; 01-07-2013 at 06:27 AM.

Thread Information

Users Browsing this Thread

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

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