首页 > 解决方案 > 复制值直到下一列的最后一整行

问题描述

我需要从 B1 复制列 B 上的一个单元格(假设是 A1)的值,直到列 C 中最后使用的行(假设是 C15 - 这意味着我需要从 B1 复制到 B15)

到目前为止,我没有任何代码 - 我是初学者

任何帮助都感激不尽!

标签: excelvbacopycopy-paste

解决方案


这可以使用 VBA 完成,如下所示

Sub fill()
  'counting last row in Column C
  lrow = Cells(Rows.Count, 3).End(xlUp).Row

  'copying Range A1 to all cells on Column B until last row in Column C
  Range(Cells(1, 2), Cells(lrow, 2)).Value = Cells(1, 1)
End Sub

推荐阅读