本文介绍了VBA填充非空白旁边的3个空白单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下是我要完成的工作的一个示例:
Here is an example of what I am trying to accomplish:
我正在尝试在非空白单元格(从左到右)旁边的接下来的3个空白单元格中添加"x".我不想覆盖任何单元格.正如您在第一行中看到的那样,只有12月和1月填写,而我并没有覆盖2月.
I am trying to add an "x" in the next 3 blank cells that are next to a nonblank cell (from left to right). I do not want to overwrite any cells though. As you can see in the first row, only December and January are filled and I did not overwrite February.
有什么想法吗?
推荐答案Sub sub1() Dim irow&, icol&, n& For irow = 2 To 6 ' rows n = 0 For icol = 2 To 14 ' columns If Cells(irow, icol) = "" Then n = n + 1 If n <= 3 Then Cells(irow, icol) = "x" Else n = 0 End If Next Next End Sub
更多推荐
VBA填充非空白旁边的3个空白单元格
发布评论