如果您很難找到開始的位置,可以嘗試使用此Sheet1的Worksheet_Change事件宏。
Option Explicit
Private dALL As Double
Private Sub Worksheet_Change(ByVal Target As Range)
If Application.Sum(Target.Parent.UsedRange.Cells) <> dALL Then
dALL = Application.Sum(Target.Parent.UsedRange.Cells)
On Error GoTo bm_Safe_Exit
'suspend events so nothing on Sheet2 gets triggered
Application.EnableEvents = False
Dim a As Long, i As Long, j As Long, aVALs As Variant
aVALs = Target.Parent.UsedRange.Cells.Value2
For i = LBound(aVALs, 1) To UBound(aVALs, 1)
For j = LBound(aVALs, 2) To UBound(aVALs, 2) - 1
If Not CBool(Len(aVALs(i, j))) Then
For a = j + 1 To UBound(aVALs, 2)
If CBool(Len(aVALs(i, a))) Then
aVALs(i, j) = aVALs(i, a)
aVALs(i, a) = vbNullString
Exit For
End If
Next a
End If
Next j
Next i
With ThisWorkbook.Worksheets("Sheet2")
.UsedRange.Clear
.Cells(1, 1).Resize(UBound(aVALs, 1), UBound(aVALs, 2)) = aVALs
End With
End If
bm_Safe_Exit:
Application.EnableEvents = True
End Sub
你的'VBA或宏觀知識'不僅看起來'非常基本';事實上,它似乎並不存在。 – Jeeped
嗯,沒錯。任何建議或方向將不勝感激。無論如何,我可以改善我的問題? – vungvang
我投票結束您的問題,因爲您要求提供代碼而不提供任何代碼。這不是獲得免費代碼的地方,你太懶惰或無法編寫代碼。改進你的問題:**寫代碼並在你的問題中包含它,並描述任何錯誤或問題**([問]]。 – Jeeped