none
How to Print the Two sorted array in VBA word? RRS feed

  • Question

  • HELLO,

    I struggle up for last two days for this issue. Here i explained it and give my code. Please anyone look into this and help me to resolve.

    Requirements:

    I have Array() values having only Year information

    Array(0) = (Deepak) 1987
    Array(1) = (G.Lakshmi) 1985
    Array(2) = (U.Dev) 1988
    Array(3) = (G.Kannan) 1985
    Array(4) = (D.Dhana) 1988

    I sorted this array Chronologically

    Code:
     WordBasic.SortArray Array()

    So that i Got the values: 

    Sortarray(0) = (G.Lakshmi) 1985
    Sortarray(1) = (G.Kannan) 1985
    Sortarray(2) = (G.Deepak) 1987
    Sortarray(3) = (U.Dev) 1988
    Sortarray(4) = (D.Dhana) 1988

    Again i have to sort this array values alphabetically So that i need to print this values 

    Sortarray1(0) = (G.Kannan) 1985
    Sortarray1(1) = (G.Lakshmi) 1985
    Sortarray1(2) = (G.Deepak) 1987
    Sortarray1(3) = (D.Dhana) 1988
    Sortarray1(4) = (G.Dev) 1988


    Code:
     Dim i1 as integer
    Dim j1 as integer
    Dim II As Integer
    Dim JJ As Integer
    Dim KK As Integer
    Dim N As Integer
    Dim Counter As Integer

    i1 having the value of LBArray and J1 the value of UBArray

    For II = 0 To UBound(SortArray())
    Counter = 1
    For JJ = II + 1 To UBound(SortArray())
    If SortArray(II) = SortArray(JJ) Then
    Counter = Counter + 1
    MsgBox (Counter)
    End IfNext JJ
    If Counter = 1 Then
    For N = i1 To J1
    If SortArray(II) = Array(N) Then
    Selection.TypeText Text:="(" & Authorname(N) & Array(N) & ")"
    End If
    Next N
    End If
    JJ = JJ + Counter
    Next II

    It produce the output of Values

    Output(0) = (G.Lakshmi) 1985
    Output(1) = (G.Kannan) 1985
    Output(2) = (G.Deepak) 1987
    Output(3) = (U.Dev) 1988
    Output(4) = (D.Dhana) 1988

    So how to print this name in ascending order?

    Tuesday, June 12, 2012 7:06 AM

All replies