向下填充公式直到列中的最后一行 [英] Fill formula down till last row in column

查看:187
本文介绍了向下填充公式直到列中的最后一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将单元格M3中的公式下拉到数据集的末尾.

I'm trying to draw down the formula that's in cell M3 to the end of the data set.

我以L列为基础来确定最后一个包含数据的单元格.我的公式是两个单元格的串联,两个单元格之间用文本逗号隔开.

I'm using column L as my base to determine the last cell with data. My formula is a concatenation of two cells with a text comma in-between them.

我的公式是= G3&,"& L3

My formula is =G3&","&L3

我希望Excel能够绘制此公式,

I want Excel to draw down this formula so

单元格M4为= G4&,"& L4
单元格M5为= G5&,"& L5,依此类推.

Cell M4 would be =G4&","&L4
Cell M5 would be =G5&","&L5 and so on.

我的代码:

Range("$M$3").Formula = Range("G3") & (",") & Range("L3")

Dim Lastrow As Long

Application.ScreenUpdating = False

Lastrow = Range("L" & Rows.Count).End(xlUp).Row
Range("M4").FormulaR1C1 = Range("G4") & (",") & Range("L4")
Range("M4").AutoFill Destination:=Range("M4:M" & Lastrow)
ActiveSheet.AutoFilterMode = False
Application.ScreenUpdating = True

我的输出是将M3单元格中的文本值一直下拉到数据集的末尾.我已经搜索了几个小时,试图寻找一种解决方法,但是找不到试图实现我想要的解决方案.

My output is pulling down the text values from cell M3 all the way down to the end of the data set. I've searched around for several hours trying to look for a fix, but can't find one that is trying to accomplish what I'm going for.

推荐答案

实际上是一个班轮.无需使用.Autofill

It's a one liner actually. No need to use .Autofill

Range("M3:M" & LastRow).Formula = "=G3&"",""&L3"

这篇关于向下填充公式直到列中的最后一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆