1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
Public Sub Main()
Application.ScreenUpdating = False
Dim Connex As New ADODB.Connection
Dim Rs As ADODB.Recordset
Set Rs = New ADODB.Recordset
Dim Cstring As String
Cstring = "Provider=PCSOFT.HFSQL;Data Source=192.168.0.237;User ID=admin;Initial Catalog=SIO"
Connex.Open (Cstring)
Set Rs = Connex.Execute("SELECT * FROM documentsgapiece INNER JOIN gapiece ON documentsgapiece.gpcleunik = gapiece.gpcleunik")
Dim i As Integer
For i = 0 To Rs.Fields.Count - 1
'ActiveSheet.Cells(1, i + 1) = i + 1
ActiveSheet.Cells(1, i + 1) = Rs.Fields(i).Name
Next
ActiveSheet.Range("A2").CopyFromRecordset Rs
'ActiveSheet.Range("A3").CopyFromRecordset Rs
Rs.Close
Connex.Close
Call permut(1, 4)
Call permut(2, 11)
Call permut(3, 12)
Call permut(4, 45)
Call permut(1, 4)
Call permut(2, 4)
Call permut(2, 3)
Dim Rg As Range
' Set Rg = Sheets("Feuil1").Range("A2").CurrentRegion
Set Rg = Sheets("Feuil1").Range("A1").CurrentRegion
ActiveSheet.ListObjects.Add(xlSrcRange, Rg, , xlYes).Name = _
"Tableau1"
Range("Tableau1[#All]").Select
Application.ScreenUpdating = True
End Sub
Public Sub permut(col1 As Integer, col2 As Integer)
Dim c1 As Integer, c2 As Integer
c1 = IIf(col1 < col2, col1, col2)
c2 = IIf(col1 > col2, col1, col2)
Application.ScreenUpdating = False
Columns(c2).Copy
Columns(c1).Insert
Columns(c1 + 1).Cut Cells(1, c2 + 1)
Columns(c1 + 1).Delete
End Sub |
Partager