Re: Data Rotation
Hi..
I've tried to do like you said.
Is it like this?
Sub cmdRotate_Click()
Sub Rotate_from_Here(xRay As Range)
Dim vLegend As Range, hLegend As Range
Dim dataRay As Range, temp As Variant, i As Long
Dim vRRay As Variant, hRRay As Variant
Set vLegend = Range(xRay.Cells(1, 1), xRay(xRay.Rows.Count - 1, 1))
Set hLegend = Range(xRay.Cells(xRay.Rows.Count, 1), xRay.Cells(xRay.Rows.Count, xRay.Columns.Count))
Set dataRay = Range(xRay.Cells(1, 2), xRay.Cells(xRay.Rows.Count - 1, xRay.Columns.Count))
vRRay = Application.Transpose(vLegend.Value)
hRRay = Application.Transpose(Application.Transpose(hLegend.Value))
For i = 1 To Int(UBound(hRRay) / 2)
temp = hRRay(i)
hRRay(i) = hRRay(UBound(hRRay) + 1 - i)
hRRay(UBound(hRRay) + 1 - i) = temp
Next i
Call rotate90counterclockwise(dataRay)
Range(xRay.Cells(1, 1), xRay.Cells(UBound(hRRay), 1)).Value = Application.Transpose(hRRay)
Range(xRay.Cells(UBound(hRRay), 2), xRay.Cells(UBound(hRRay), UBound(vRRay))) = vRRay
End Sub
Sub rotate90counterclockwise(inRay As Range)
Dim outRay As Range
Dim inDataRRay As Variant, outDataRRay
Dim i As Long, j As Long
Dim high1 As Long, high2 As Long
inDataRRay = inRay.Value
high1 = UBound(inDataRRay, 1)
high2 = UBound(inDataRRay, 2)
ReDim outDataRRay(1 To high2, 1 To high1)
For i = 1 To high1
For j = 1 To high2
outDataRRay(high2 - j + 1, i) = inDataRRay(i, j)
Next j
Next i
Set outRay = inRay.Cells(1, 1)
Set outRay = Range(outRay, outRay.Cells(high2, high1))
outRay.Value = outDataRRay
End Sub
Call Rotate_from_Here(RotateThisRange)
End Sub
Display More
When I clicked the button. Nothing happen?
Why?If anything that I need to add in or change?