选择范围内不为空的行

时间:2018-01-23 06:55:18

标签: excel excel-vba vba

我有一些包含数据的列。我打算select然后使用工作簿信封发送。问题是有些单元格是空的,我不想选择它们。

如何避免列E具有空白值的行?

这是我到目前为止所尝试的。

' This will select all
ThisWorkbook.Sheets("holo").Range("A10:D100,E10:E100").Select

' Tried using If 
Dim rg As Range
For Each rg In ThisWorkbook.Sheets("holo").Range("A10:D100,E10:E100").Select
If rg <> "" Then
rg.Select
Debug.Print rg.Address + "is not empty"
End If
Next

1 个答案:

答案 0 :(得分:1)

如果E列中的值是键入的值并且未从公式中解析,请尝试

dim rg as range
with worksheets("holo").usedrange
   on error resume next
   set rg = .columns("E").specialcells(xlCellTypeConstants, 7)
   on error goto 0
   if not rg is nothing then
       'do something with rg
   end if
end with
相关问题