Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2004
    Posts
    72

    Unanswered: moving column i9n table in alphabetical order

    In VBA for Excel macro...please

    is possible to ordering in alphabetical mode the column in table with a VBA code...?

    path of mdb=c:\db2.mdb
    table name=test

    have in table this column named
    aaa
    cccc
    bbb

    i want in table after code reordering the column in
    aaa
    bbb
    ccc

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    select aaa, ccc, bbb from yourTable ?

    Also, you say this is a vba macro for excel, then provide two lines of code that don't mean anything but implicate you're working with access. Can you be a little more forthcoming with details?
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Oct 2004
    Posts
    72
    Quote Originally Posted by Teddy
    select aaa, ccc, bbb from yourTable ?

    Also, you say this is a vba macro for excel, then provide two lines of code that don't mean anything but implicate you're working with access. Can you be a little more forthcoming with details?
    hI Teddy, peraphS solved with this code, but i want to exclude from the column ordering the field named "DATA_AGG" (attached example of mdb):
    Code:
    Option Explicit
    Sub ORDER_FILEDS()
    
        Dim DATABASE As DAO.DATABASE
        Dim TABELLA As DAO.TableDef
        Dim CAMPO_TEMP As DAO.Field
        Dim POSIZIONE() As Integer
        Dim CAMPO_NOME() As String
        Dim INT_TEMP As Integer
    
        Set DATABASE = OpenDatabase("C:\OPERATORI.mdb")
        Set TABELLA = DATABASE.TableDefs("TEST")
    
        With TABELLA
    
            ReDim POSIZIONE(0 To .Fields.Count - 1) As Integer
            ReDim CAMPO_NOME(0 To .Fields.Count - 1) As String
    
            For INT_TEMP = 0 To .Fields.Count - 1
                POSIZIONE(INT_TEMP) = .Fields(INT_TEMP).OrdinalPosition
                CAMPO_NOME(INT_TEMP) = .Fields(INT_TEMP).Name
            Next INT_TEMP
    
            For Each CAMPO_TEMP In .Fields
                CAMPO_TEMP.OrdinalPosition = 1
            Next CAMPO_TEMP
    
        End With
    
        DATABASE.Close
    
    End Sub
    Last edited by sal21; 01-11-09 at 07:31.

Posting Permissions

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