[英]How to pause macro while user enters a value in a cell and then unpause macro
[英]A macro that looks up a value in a cell then enters a "x" into another cell
有人可以就宏代码向我提供建议,该代码将查找我在单元格中键入的值。
然后在单元格的同一行但右侧 4 列中输入字母 x ? 然后保存。
想法是在单元格中输入文本按一个按钮,然后查找它然后在另一个单元格中添加一个 x 并保存结尾子。??
Sub MakeTheChanges()
Dim BayControl As Worksheet Set BayControl = ThisWorkbook.Sheets("Bay control")
BayControl.Range("A" & BayControl.Range("M1").Value + 1) = "BAY CLEAR"
BayControl.Range("C" & BayControl.Range("M1").Value + 1) = ""
BayControl.Range("D" & BayControl.Range("M1").Value + 1) = "N/A"
BayControl.Range("M1") = ""
End Sub
关于我对您可能正在寻找的内容的解释,请参见下文:
Sub EnterThexA()
Dim Sunday As Worksheet, xRange As Range
' If E1 contains an error, just give up.
If IsError(Range("E1")) Then Exit Sub
' If E1 doesn't have any value, just give up.
If Len(Range("E1").Value) = 0 Then Exit Sub
Set Sunday = ThisWorkbook.Sheets("Sunday")
' See if you can find whatever is in range "E1" in column A, if so, set xRange to that Cell
Set xRange = Columns("A:A").Find(What:=Range("E1").Value, LookIn:=xlValues, Lookat:=xlWhole)
' If you in fact found something
If Not xRange Is Nothing then
' You want the x in column E, which is 4 places to the right.
Set xRange = xRange.Offset(0, 4)
xRange.Value = "x"
End If
' Set certain variables to nothing (just good form, not really necessary)
Set Sunday = Nothing: Set xRange = Nothing
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.