Excel:如何粘贴到第一个空白单元格? [英] Excel: how to paste to first blank cell?

查看:347
本文介绍了Excel:如何粘贴到第一个空白单元格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将信息粘贴到工作表的列A中的第一个空白单元格?我该怎么做?

I'm trying to paste info to the first blank cell in colum A of a sheet? How can I do this?

这是我已经做的,但粘贴信息1000次。我需要改变什么?

This is what I have done but it paste the info 1000 times. What do I need to change?

提前感谢

Range("B2:E2").Select                                        'Selet info to copy
Selection.Copy                                               'Copy
Sheets(Range("A2").Value).Select                             'Goto Sheet Listed in cell A2

Dim i                                                        'define i
    For i = 3 To 1000                                        'Set up loop size
        If Range("A" & CStr(i)).Value = "" Then              'If Cell Ai is blank
            Range("A" & i).Select
            ActiveSheet.Paste                                'Paste info
        End If
    Next i
    End If


推荐答案

您的 FOR LOOP 将从单元格 A3 运行,直到 A1000 ,并为每个空单元格粘贴该值。一旦条件匹配,您就想退出循环。您要添加退出条件。

Your FOR LOOP will run from cell A3 until A1000 and for every empty cell it will paste the value. You want to exit your loop as soon as the condition is matched. You want to add an Exit For condition.

If Range("A" & CStr(i)).Value = "" Then
    Range("A" & i).Select
    ActiveSheet.Paste
    Exit For
End If

来源

这篇关于Excel:如何粘贴到第一个空白单元格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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