选择列中的所有空白单元格 [英] Select all blanks cells in a column

查看:53
本文介绍了选择列中的所有空白单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现以下代码可以选择列中的下一个空白单元格.此代码查找下一个空白单元格(数据从A1开始).假设我有来自A1-A15的数据,然后有一个空白单元格.这段代码确实选择了A16,因为它是下一个空白单元格.

I have found below code to select next blank cell in a column. This code finds the next blank cell (data starting from A1). Suppose I have data from A1-A15 then a blank cell. This code does select A16 as it is next blank cell.

但是我下面有更多数据,我想选择每组数据下的所有空白单元格.请建议如何修改此代码,以便它可以遍历整个A列并选择所有下一个空白单元格(如果我理解所写的内容).谢谢

However I have more data below and I want to select all blank cells under each set of data. Please advise how to amend this code so that it can go through the whole of column A and select all next blank cells (If I make sense of what I have written). Thanks

Sub FindNextCell()
'Locate the next data entry cell in data entry column A
Dim FirstCell As String
Dim i As Integer
FirstCell = "A1"
Range(FirstCell).Select
Do Until ActiveCell.Value = ""
If ActiveCell.Value = "" Then
Exit Do
Else
ActiveCell.Offset(1, 0).Select
End If
Loop
End Sub

推荐答案

如果要选择第一个和最后一个单元格之间的所有空白,则可以使用此

If you want to select all the blanks between the first and last cell you could use this

Dim lr As Long
lr = Range("A" & Rows.Count).End(xlUp).Row

Range("A1:A" & lr).SpecialCells(xlCellTypeBlanks).Select

注意:避免使用.Select

这篇关于选择列中的所有空白单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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