0
2つの連続したセルをそれぞれ比較したい場合、その値が同じ場合は、それらの間に空のセルを作成したい。つまり、A1==B1
の場合は、B1
の値を右に移動して、プログラムを右クリックしてセルをB1
に挿入します。私は私が持っているすべての行のためにこれをしたいです。残念ながら、私はVBAの知識を制限し、記録マクロで遊んで、オンラインを見てきた、私は次のforループを使用して等価な値を見つけ、それらの間にセルを作成したい
' dim is dimension
' allows us to declare variable names and their type
Dim i As Integer, j As Integer
With ActiveSheet.UsedRange
'.Row.Count (.Columns.Count) gives the index of rows (columns) used. If we don't use ., it will give us the end...
For i = 1 To .Rows.Count
For j = 1 To .Columns.Count
If ActiveSheet.Cells(i, j).Value = ActiveSheet.Cells(i, j + 1).Value And Not IsEmpty(ActiveSheet.Cells(i, j).Value) Then ActiveSheet.Cells(i, j + 1).Select , Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
End If
Next j
Next i
End With
しかし、Excelはコンパイルエラーを返しました。ブロックせずに
END IF
が、私は私のミスはあなたがIf
を使用するには、2つの方法で持って
Then ActiveSheet.Cells(i, j + 1).Select , Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
で
を置き換えることができます秒でそれに私を打つ:) –
はご協力いただきありがとうございます。それは魅力のように働いた。 – Koskarium