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
グレート提案を、非常に簡単。それはあなたが記述した通りに正確に働いた。答えをありがとう。 –