VBA填充非空白旁边的3个空白单元格

编程入门 行业动态 更新时间:2024-10-28 00:27:39
本文介绍了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个空白单元格

本文发布于:2023-10-30 13:39:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1543017.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:空白   单元格   VBA

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!