使用Excel VBAmacros将值从一列添加到另一列

我需要一个VBAmacros,将“Unclassified”列中的值添加到“Corporate”中。

我不能用公式来做这件事,因为我必须在之后完全删除Unclassified列。

例如:

之前

会变成:

后

让我知道这个是否奏效

 Sub CorporateAdd() Application.ScreenUpdating = False Dim TotalRows As Long Dim UnclassArray As Variant, CorporateArray As Variant TotalRows = Range("L1048576").End(xlUp).Row UnclassArray = Columns("N") CorporateArray = Columns("L") For i = 4 To TotalRows CorporateArray(i, 1) = CorporateArray(i, 1) + UnclassArray(i, 1) Next i Columns("L") = CorporateArray 'Uncomment this if you want it to automatically delete "Unclassified" 'Columns("N").Delete Shift:=xlLeft Application.ScreenUpdating = True End Sub 

但是,为了将来的参考,我不认为人们喜欢当你要求代码,先试试自己,如果它不工作来这里帮助修复它! 🙂