0
在Excel中我有一个VBA函数返回由用户选择的单元格中文本的连接字符串。检查所选范围内的单元格是否可见
这可以按我的要求工作,但是如果在选择中存在隐藏的单元格,隐藏单元格的值将包含在内,这是不可取的。发生此问题的一个示例是过滤表。
有没有办法修改我的函数来检查正在读取的单元格是否可见?
Sub ConcatEmialAddresses()
Dim EmailAddresses As String
ActiveSheet.Range("C3").Value = combineSelected()
ActiveSheet.Range("C3").Select
Call MsgBox("The email address string from cell ""C3"" has been copied to your clipboard.", vbOKOnly, "Sit back, relax, it's all been taken care of...")
End Sub
Function combineSelected(Optional ByVal separator As String = "; ", _
Optional ByVal copyText As Boolean = True) As String
Dim cellValue As Range
Dim outputText As String
For Each cellValue In Selection
outputText = outputText & cellValue & separator
Next cellValue
If Right(outputText, 2) = separator Then outputText = Left(outputText, Len(outputText) - 2)
combineSelected = outputText
End Function
伟大的建议,而且很容易。它完全按照您所描述的那样工作感谢你的回答。 –