[FONT=Fixedsys]Option Explicit[/FONT]
[FONT=Fixedsys][/FONT]
[FONT=Fixedsys]Public Sub TransposeData()[/FONT]
[FONT=Fixedsys][/FONT]
[FONT=Fixedsys] Dim ws As Worksheet
Dim wkbk As Workbook
Dim wss As Worksheet
Dim iLastCol As Integer
Set ws = ThisWorkbook.[COLOR=red]Sheets(1)[COLOR=green] ' sheet where this program writes the data[/COLOR]
[/COLOR] Set wkbk = Workbooks.Open(Filename:="K:\CLE03\Son\Component_View_in_Excel.xls", ReadOnly:=True)
Set wss = wkbk.[COLOR=red]Sheets(1) [COLOR=green]' sheet in output file from Access query[/COLOR]
[/COLOR]
ws.UsedRange.ClearContents
iLastCol = wss.Cells(1, wss.Columns.Count).End(xlToLeft).Column
wss.Range("B1").Resize(2, iLastCol - 1).Copy
With ws
.Range("A1").PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:=False, Transpose:=True
.Columns("A:B").ColumnWidth = 100
.Columns("A:B").EntireColumn.AutoFit
.Rows("1:" & iLastCol).RowHeight = 30
.Rows("1:" & iLastCol).EntireRow.AutoFit
End With
wkbk.Close SaveChanges:=False
[COLOR=blue] [/COLOR][COLOR=blue]ThisWorkbook.Save
[/COLOR]
End Sub[/FONT]