作者:4号的国哥 | 来源:互联网 | 2023-07-04 15:13
I am working on a macro to do a repetitive task for me. To give you a clear view, I have prepared my initial macro (vba) code below as well as the flow chart of what it suppose to do:
我正在研究一个宏来为我做一个重复的任务。为了给你一个清晰的视图,我准备了下面的初始宏(vba)代码以及它想要做的事情的流程图:
Here a narrative description of the macro:
这里是宏的叙述性描述:
- Check all the cells in Column K if it contains the word "MERGED"
检查K列中的所有单元格是否包含单词“MERGED”
- IF the macro found the word "Merged", it will call another macro (Macro_X)
如果宏发现单词“Merged”,它将调用另一个宏(Macro_X)
- After calling the Macro, it will check again all the cells in Column K if it still contains the word "MERGED"
调用宏后,如果它仍包含单词“MERGED”,它将再次检查K列中的所有单元格
- If the macro still finds the word "Merged", it will call again the Macro_X.
如果宏仍然找到单词“Merged”,它将再次调用Macro_X。
- The condition will only stop until the Column K doesn't contain the word "Merged".
条件只会停止,直到列K不包含单词“Merged”。
If the macro didn't find any "Merged" word in column K, it will now call the Macro_Z.
如果宏没有在列K中找到任何“合并”字,它现在将调用Macro_Z。
Last = Cells(Rows.Count, "K").End(xlUp).Row
For i = Last To 1 Step -1
If (Cells(i, "K").Value) = "Merged" Then
Call macro_x
End If
Next I
![enter image description here](https://img1.php1.cn/3cd4a/24c6f/78c/279d73495e786518.jpeg)
Screen shot of column K
列K的屏幕截图
![enter image description here](https://img1.php1.cn/3cd4a/24c6f/78c/d95129a4a2e18a28.jpeg)
I already have the code above but it's not working. Not sure why. Could you please help to point out what's wrong or suggest a better code?
我已经有上面的代码,但它不起作用。不知道为什么。你能帮忙指出什么是错的或建议更好的代码吗?
3 个解决方案