旋转值的macros

我目前正在制作一个包含多列的电子表格,在每一列中都有第10,11和12行,表示您是否是第1,2,3号。 更具体地说,看下面的图片。

http://i.imgur.com/QezrzqW.png

我需要构build一个macros,每次使用它的值都会改变,所以A列中的单元格将变为A10 = 1,A11和A12 =空白,B列B12 = 3,B10和B12 =空白,C列到C11 = 2,C10和C12 =空白)等。macros将运行,直到列AC到达。

有没有办法做到这一点? 我必须每天更改这些值,这样对于多列可能会变得非常繁琐。

亲切的问候,雷神

您的问题不清楚如何列A被填入,但像这样的事情应该做的伎俩:

Public Sub MoveRight() Dim sh As Worksheet Dim area As Range Set sh = ActiveSheet With sh Set area = .Range(.Cells(10, 1), .Cells(12, 29)) End With Dim r As Long, c As Long With area For c = .Columns.Count To 2 Step -1 For r = 1 To .Rows.Count .Cells(r, c).Value = .Cells(r, c - 1).Value Next r Next c For r = 1 To .Rows.Count If .Cells(r, 4).Value = r Then .Cells(r, 1).Value = r Else .Cells(r, 1).Value = vbNullString End If Next r End With End Sub 

不是很优雅,但这是你所描述的…

 Option Explicit Option Base 1 Sub Simple() Dim iloop As Integer For iloop = 1 To 29 If Sheets("Sheet1").Cells(10, iloop) = 1 Then Sheets("Sheet1").Cells(10, iloop) = "" Sheets("Sheet1").Cells(11, iloop) = 2 Else If Sheets("Sheet1").Cells(11, iloop) = 2 Then Sheets("Sheet1").Cells(11, iloop) = "" Sheets("Sheet1").Cells(12, iloop) = 3 Else If Sheets("Sheet1").Cells(12, iloop) = 3 Then Sheets("Sheet1").Cells(12, iloop) = "" Sheets("Sheet1").Cells(10, iloop) = 1 End If End If End If Next iloop End Sub