|
这个代码的作用是可以实现对成批的数据进行整体变换的功能,比如说将所有的数据整理扩大或者缩小1000倍.如果你的老板叫你把UNIT从普通变成千或万,这个代码可以一次实现.
Sub rangechange()
Dim i As Integer
Dim j As Integer
Dim x As Integer
Dim y As Integer
Dim m As Integer
Dim n As Integer
Dim myarea As Range
Dim mycell() As Long
Set myarea = ActiveWindow.RangeSelection
x = myarea.Rows.Count
y = myarea.Columns.Count
m = ActiveCell.Row
n = ActiveCell.Column
ReDim mycell(x, y)
For i = 0 To x - 1
For j = 0 To y - 1
mycell(i, j) = ActiveSheet.Cells(m + i, n + j).Value
Next j
Next i
For i = 0 To x - 1
For j = 0 To y - 1
ActiveSheet.Cells(m + i, n + j).Value = mycell(i, j) / 1000
Next j
Next i
End Sub
这个是我自己做的,可以改进的地方是可不可以实现不连续区域的改变,请大家帮忙扩展啊 |
|