Consulting

Results 1 to 13 of 13

Thread: Check the order

  1. #1

    Check the order

    Hi,
    Actually i want check the structure placed in column D of the excel sheet and needs to validate the same
    i require the coding partof it in VB


    A.02222----------------row 1
    A.02222.1-------------row2
    A.02222.1.01
    A.02222.1.02
    A.02222.2
    A.02222.2.01
    A.02222.3

    Invalid structure

    A.02222----------------row 1
    A.02222.1-------------row2
    A.02222.1.01
    A.02222.1.02
    A.02222.1.04-----------------invalid
    A.02222.1.03
    A.02222.2.02-----------------invalid
    A.02222.2
    A.02222.2.01
    A.02222.3

    Kindly help

  2. #2
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    From the macro recorder. if you have more than 100 rows you will have to change that in the code.
    [VBA]Sub Macro1()
    Rows("1:100").Select
    Selection.Sort Key1:=Range("D1"), Order1:=xlAscending, Header:=xlGuess, _
    OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
    DataOption1:=xlSortNormal
    End Sub[/VBA]
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  3. #3

    Format

    Hi

    Actually my excel sheet column D contains the data as follows
    I need to check the validity of this kind of structure in VBA

    A.02222
    A.02222.1
    A.02222.1.01
    A.02222.1.02
    A.02222.1.03
    A.02222.2
    A.02222.2.01 ?Values not required to be consecutive but should
    A.02222.2.03 ?keep the order
    A.02222.2.05
    A.02222.2.07
    A.02222.3
    A.02222.3.1

    Kindly help
    Thanks and Regards
    Priya

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    It would be good to keep topics in a single thread rather than proliferate the information across many threads, and it needs a lot more explanation than that, it would need a mind-reader to know what you mean.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    Hi

    Actually what I require is to check that whether the order is followed in column D i.e

    A.02222 this value is in cell(d1)
    A.02222.1 this value is in cell(d2) and follows
    A.02222.1.01
    A.02222.1.02
    A.02222.1.03
    A.02222.1.05 --------------this is since 3 should follow 4
    A.02222.1.04

    Thanks
    Priya

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    You could use conditional formatting with a formula of

    =AND(D2<>"",D1>D2)
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  7. #7
    Hi
    Lucas

    I tried the above code but it gives an error saying application or object defined error

    Thanks
    Priya

  8. #8
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Good idea, keep two threads on the same subject running at the same time.

    You buddy are now on my 'kill' list.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  9. #9
    Hi
    Actually i didnt remember i had posted earlier so after getting the reply for the other post i continued with this one
    Sorry for the inconvienence

    Thanks
    Priya

  10. #10
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    so where is the other post? How about a link to it at least
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  11. #11
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Threads merged.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  12. #12
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,059
    Location
    Hmmm....... Bob the Assassain. Nope just doesn't have that ring to it.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  13. #13
    [VBA]
    Sub check()
    Set d = Columns("D").Find("")
    For i = 1 To d.Row - 1
    If Cells(i, 4) > Cells(i + 1, 4) Then Cells(i, 5) = "AAAAAAAAAAaaaaaaaaaaarrrgrh!"
    Next i
    End Sub
    [/VBA]

    It's not the worst thing ever, but work on your forum etiquette:
    @ useful thread title
    @ no cross-posting
    @ not being a general arse. You get the help for free, obeying the rules is a pretty small price.

Posting Permissions

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