DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
Altın Üyelik Hakkında Bilgi
Sub adoTranspose()
Dim adoCn As Object, rs As Object
Dim sonA&, strSql$, i&
Range("G:Z").Clear
Set adoCn = CreateObject("ADODB.Connection")
adoCn.Provider = "Microsoft.ACE.OLEDB.12.0"
adoCn.Properties("Data Source") = ThisWorkbook.FullName
adoCn.Properties("Extended Properties") = "Excel 12.0; HDR=YES"
adoCn.Open
Set rs = CreateObject("Adodb.RecordSet")
sonA = Cells(Rows.Count, 1).End(3).Row
strSql = "TRANSFORM FIRST(CEVAP) SELECT ID FROM [Sheet1$A1:C" & sonA & "] " & _
"GROUP BY ID ORDER BY SORU ASC PIVOT SORU"
rs.Open strSql, adoCn
For i = 0 To rs.Fields.Count - 1
With Cells(1, i + 7)
.Clear
.Value = rs.Fields(i).Name
.Font.Bold = True
.Font.Color = vbWhite
.Interior.Color = vbBlack
.HorizontalAlignment = xlCenter
End With
Next
[G2].CopyFromRecordset rs
Columns.AutoFit
rs.Close
adoCn.Close
Set rs = Nothing
Set adoCn = Nothing
End Sub
Bunu ben de bilmiyordum. Son zamanlarda sıkça kullandığım bir özellikti. Bu gibi durumlarda ne yapılması gerekiyor acaba?Ado 65536 satır ve 255 sütunda çalışır.
Sub adoTranspose()
Dim adoCn As Object, rs As Object
Dim strSql$, i&
Range("G:Z").Clear
Set adoCn = CreateObject("ADODB.Connection")
adoCn.Provider = "Microsoft.ACE.OLEDB.12.0"
adoCn.Properties("Data Source") = ThisWorkbook.FullName
adoCn.Properties("Extended Properties") = "Excel 12.0; HDR=YES"
adoCn.Open
Set rs = CreateObject("Adodb.RecordSet")
strSql = "TRANSFORM FIRST(CEVAP) SELECT ID FROM [Sheet1$A:C] " & _
"GROUP BY ID ORDER BY SORU ASC PIVOT SORU"
rs.Open strSql, adoCn
For i = 0 To rs.Fields.Count - 1
With Cells(1, i + 7)
.Clear
.Value = rs.Fields(i).Name
.Font.Bold = True
.Font.Color = vbWhite
.Interior.Color = vbBlack
.HorizontalAlignment = xlCenter
End With
Next
[G2].CopyFromRecordset rs
Columns.AutoFit
rs.Close
adoCn.Close
Set rs = Nothing
Set adoCn = Nothing
End Sub
Sub transpose()
Application.ScreenUpdating = False
Dim sonSat&, sonSut&, i&
Dim dicSut As Object, dicSat As Object
Set dicSut = CreateObject("Scripting.Dictionary")
Set dicSat = CreateObject("Scripting.Dictionary")
[G:XFD].Clear
[B:B].Copy [G1]
[G:G].RemoveDuplicates Columns:=1, Header:=xlYes
sonSut = Cells(Rows.Count, "G").End(3).Row
Range("$G1:$G" & sonSut).Sort [G1], xlAscending, , , , , , xlYes
Range("$G2:$G" & sonSut).Copy
For i = 2 To sonSut
dicSut(Cells(i, "G").Value) = i + 6
Next i
[H1].PasteSpecial transpose:=True
[G:G].Clear
[A:A].Copy [G1]
[G:G].RemoveDuplicates Columns:=1, Header:=xlYes
sonSat = Cells(Rows.Count, "G").End(3).Row
Range("$G1:$G" & sonSat).Sort [G1], xlAscending, , , , , , xlYes
For i = 2 To sonSat
dicSat(Cells(i, "G").Value) = i
Next i
sonSat = Cells(Rows.Count, "A").End(3).Row
For i = 2 To sonSat
Cells(dicSat(Cells(i, 1).Value), dicSut(Cells(i, 2).Value)).Value = Cells(i, 3).Value
Next i
Application.ScreenUpdating = True
End Sub