Glasgowsmile
Active Member
- Joined
- Apr 14, 2018
- Messages
- 280
- Office Version
- 365
- Platform
- Windows
Good day,
I have the following code and I need to transpose one of the returns but I'm unsure how to easily go about it.
I have the following code and I need to transpose one of the returns but I'm unsure how to easily go about it.
VBA Code:
Dim wkbCrntWorkBook As Workbook
Dim wkbSourceBook As Workbook
Dim sh As Worksheet, ws As Worksheet
Dim rg1 As Variant, rg2 As Variant, rg3 As Variant
Dim r1 As Long, c1 As Long
Dim r2 As Long, c2 As Long
Dim r3 As Long, c3 As Long
Set wkbCrntWorkBook = ActiveWorkbook
Set sh = ActiveSheet
If .SelectedItems.Count > 0 Then
Workbooks.Open .SelectedItems(1)
Set wkbSourceBook = ActiveWorkbook
Set ws = wkbSourceBook.Sheets(1)
With ws
rg1 = .Range("S4:S5").Value
rg2 = .Range("P9:Q33").Value
rg3 = .Range("J123:J147").Value
r1 = UBound(rg1): c1 = UBound(rg1, 2)
r2 = UBound(rg2): c2 = UBound(rg2, 2)
r3 = UBound(rg3): c3 = UBound(rg3, 2)
End With
With sh
.Range("A2").Resize(r1, c1).Value = rg1 <-- I need this transposed
.Range("A5").Resize(r2, c2).Value = rg2
.Range("C5").Resize(r3, c3).Value = rg3
End With