[英]Excel Macro - making next 2 cells blank if cell has a certain value
I'm trying to adapt a macro in an excel sheet so that if column AC = "FT" then AD and AE should be cleared. 我正在尝试在Excel工作表中调整宏,以便如果AC =“ FT”列,则应清除AD和AE。
I have tried searching for an answer but unable to find anything that works. 我尝试寻找答案,但找不到任何有效的方法。
Thanks 谢谢
If I understand your question correctly, then try the following code in the worksheet code module where you put your data. 如果我正确理解了您的问题,请在放置数据的工作表代码模块中尝试以下代码。
Sub Test()
Dim i As Long, LastRow As Long
LastRow = Cells(Rows.Count, "AC").End(xlUp).Row
For i = 1 To LastRow 'Set the value of i as a starting point depends on your first data is located
If Cells(i, "AC").Value = "FT" Then
Range(Cells(i, "AD"), Cells(i, "AE")).Clear 'Alternatively .Value = "" or .ClearContents
End If
Next i
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.