VBA Line Break

chris -  
f894009 Posted messages 17417 Registration date   Status Membre Last intervention   -
Bonjour,

I am looking for a VBA code that allows me to insert a line break after each found result during a lookup.
The current code used is as follows:

Function VLooKupList(SearchValue As Range, SearchTable As Range, ColumnNumber As Integer, SEPARATOR As String) As Variant Dim RowCount As Integer RowCount = SearchTable.Rows.Count Dim FoundValuesCounter As Integer FoundValuesCounter = 0 For i = 1 To RowCount If SearchTable(i, 1).Value = SearchValue.Value Then FoundValuesCounter = FoundValuesCounter + 1 If FoundValuesCounter > 1 Then VLooKupList = VLooKupList & Chr(10) & SearchTable(i, ColumnNumber).Value Else VLooKupList = SearchTable(i, ColumnNumber).Value End If End If Next i End Function


Thank you!!!

2 réponses

Fahora Posted messages 949 Status Membre 68
 
Hello,

Logically, Chr(10) is the right method to go to the next line (line break).
In what are you displaying your VLooKupList variable? If it's a cell, have you checked that it has automatic line wrapping enabled?

Best regards,

--
Our only limits are those we impose on ourselves.
Fahora
0