TriniCurry
TriniCurry

Reputation: 57

Transpose range in excel with VBS

Hey guys need some help here . how can I transpose a range in excel with VBS? basically copy a range from one sheet then pastespecial transpose on the other sheet. thanks in advance

Upvotes: 0

Views: 2629

Answers (2)

TriniCurry
TriniCurry

Reputation: 57

 Set objXLApp = CreateObject("Excel.Application")
 Set objXLWb = objXLApp.Workbooks.Open("C:\Users\CuRrY\Desktop\test1.xls")
 objXLApp.Application.Visible = True
 objXLApp.DisplayAlerts=False
 Set objXLWs = objXLWb.Sheets(1)  

 objXLWs.Range("A1:O1").Copy
 objXLWs.Range("A2").PasteSpecial ,,,True

from what I have seen in other scripts I wrote,wscript goes through the entire string so just added the commas and just put the transpose part as true >>>

.Range("A2").PasteSpecial ,,,True

Thanks again cronos2546 , I love this site :)

Upvotes: 1

cronos2546
cronos2546

Reputation: 1106

Public Sub transpose()
           Worksheets("Sheet1").Range("A1:A5").Copy
           Worksheets("Sheet2").Range("A1").PasteSpecial Transpose:=True
End Sub

Is this what you want?

Upvotes: 0

Related Questions