我希望压缩我的剧本,因为我仍然有很长的路要走,即使复制和粘贴这将花费我很长时间。我只是想缩小查找/替换函数
# Plot...
plt.scatter(df.x, df.y, c= df.z)
谢谢!
答案 0 :(得分:3)
如果必须进行多次查找和替换,可以将所有值放在数组中并运行循环。问题是,这会比现在慢。但是,纯粹为了缩短代码,你可以做到这一点。
Function ZoneChanges()
Dim MyCell As Range
Dim arrWhat, arrRep, i As Long
Worksheets("Sheet1").Activate
Set MyCell = Application.InputBox(prompt:="Select a cell", Type:=8)
arrWhat = Array("EE", "EF", "EG", "EH"): arrRep = Array("DA", "DB", "DC", "DD")
For i = LBound(arrWhat) To UBound(arrWhat)
MyCell.Replace What:=arrWhat(i), Replacement:=arrRep(i), LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Next
End Function