将单元格值复制到其下面的所有单元格 [英] Copy cell value to all cells below it

查看:251
本文介绍了将单元格值复制到其下面的所有单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道如何写一个宏指定一个列中的单元格作为主单元格(可编辑)副本,单元格值到该列下面的所有单元格,直到它达到空白/清除格式化的单元格在列A中。所以我想让它查看列A知道什么时候停止复制任何列中的单元格值。

I don't know how to write a macro that designates a cell within a column as a "master cell" (editable) copy that cells value to all the cells below it in that column, until it reaches a blank/clear formatted cell in column A. So I want it to look at column A to know when to stop copying the cell values in whichever column.

也就是说,单元格C5将是一个主单元格,宏将从C6:C中复制它的值,但是查看列A的单元格值,看看它是否没有任何内容,没有格式化,如颜色填充等,而不是宏继续在列C到无穷大(Excel的最大增量),它将停止在A列的第一个空白单元格行。

That is, Cell "C5" will be a master cell, the macro will copy it's value from "C6:C" but looking at column A's cell values to see if it has nothing in it and there's no formatting such as color fill, etc. and instead of the macro continuing on in column C to infinity (maximum increment for Excel) it will stop at A column's first blank cell row.

推荐答案

Sub Example()
    Dim MasterValue As String
    Dim StopRow As Long
    Dim i As Long

    'Get the master value
    MasterValue = Range("C5").Value

    'Get the first blank cell in column A
    StopRow = Range("A1").End(xlDown).Row

    'Start at row 6 and continue to the "Stop Row"
    For i = 6 To StopRow
        'Set every cell from row 6 in column 3 to the "Master Value"
        Cells(i, 3).Value = MasterValue
    Next
End Sub

这篇关于将单元格值复制到其下面的所有单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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