二位数组旋转指定角度

二维数组旋转
z

Sub 宏1()
'逆时针旋转90度
' 宏1 宏
Dim CountNum As Integer
Dim Rng As Range
Dim arr(), temArr()
Dim rowStar As Integer, rowEnd As Integer
Dim maxInt As Integer

Dim colStar As Integer, colEnd As Integer
Dim temStr As String
Set Rng = Worksheets("Sheet1").UsedRange
arr = WorksheetFunction.Transpose(Rng)
arr = WorksheetFunction.Transpose(arr)
If UBound(arr) > UBound(arr, 2) Then
    maxInt = UBound(arr)
Else
     maxInt = UBound(arr, 2)
End If
 ReDim temArr(1 To maxInt + 1, 1 To maxInt + 1)


For i = LBound(arr) To UBound(arr)
    For j = LBound(arr, 2) To UBound(arr, 2)
    CountNum = CountNum + 1
    
   '-90
   ' temArr(Abs(UBound(arr, 1) - UBound(arr, 2) - j), i) = arr(i, j)
'-180
' temArr(Abs(UBound(arr, 1) - i + 1), UBound(arr, 2) - j + 1) = arr(i, j)
 '-270
 temArr(j, Abs(UBound(arr, 1) - i) + 1) = arr(i, j)
   
    
   
Next
Next
Worksheets("Sheet2").Range("a1").Resize(UBound(temArr), UBound(temArr, 2)) = temArr
End Sub
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值