Hi All,
Can anyone tell if there is a way to read the text in a single cell line by line using VBA?
E.g. In a multiple line cell (written using Alt+Enter) containing this:
Paul Smith
22, Elk Street
Smalltown
I would like to use VBA and read the strings from the 3 lines in the cell into 3 different variables.
Many thanks!
Assuming you've used Char(10) to add the line break then you can use Split accordingly, eg:
Dim vStrings As Variant, strOne As String, strTwo As String, strThree As String vStrings = Split(Range("A1").Value,Chr(10)) strOne = vStrings(0) strTwo = vStrings(1) strThree = vStrings(2)
It follows that string variables may be moot - ie you could simply refer to vStrings(n) as and when required.
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
DonkeyOte,
Thank you very much!
It works exactly as I wanted.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks