首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >excel自动填充每第三列

excel自动填充每第三列
EN

Stack Overflow用户
提问于 2018-02-09 18:56:27
回答 1查看 328关注 0票数 1

我正在处理Excel中的产品说明书。每个规范由三列组成:例如,A列为500,B列为码,最后在C列I中,测试是否设置A列,然后将它们合并为"500码“。产品规格中使用C栏。如F栏、I栏等。

现在我知道我可以使用自动填充来填充整个C列,但是对于第三列是否必须手动填充呢?

所以我要找的是一种在第三列自动填充的方法。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-02-09 21:07:59

此代码假设在第2行的每一列上都有公式(您希望自动填充该列)。

代码语言:javascript
运行
复制
Sub Autofill_every_nth_column()
Dim RangeToFill As String

For i = 3 To 150 Step 3 'start from column 3 (i.e. column "C") and loop to column 150 (i.e. column "ET"). After every loop it jump 3 columns. So first loop it will autofill Column C, then autofill Column F etc.

    RangeToFill = Range(Cells(2, i), Cells(2, i)).Select 'Cell formula is located. This mean at Row 2 and column i, where i is the number the loop is at
    Selection.AutoFill Destination:=Range(Cells(2, i), Cells(200, i)) 'Autofill formula from row 2 to row 200.

    Next 'Jump to next loop.

End Sub

我写了一些评论,希望你能为了你的目的而修改它。请记住,excel中的自动填充函数仅在单元格中有值时才自动填充。所以即使你说:

代码语言:javascript
运行
复制
Destination:=Range(Cells(2, i), Cells(200, i)) 'Autofill formula from row 2 to row 200.

它只循环到最后一行,其中有值(最大到第200行)。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48712379

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档