Hi,
I have a similar problem to the one solved in the link below.
http://www.officekb.com/Uwe/Forum.as...ate-like-sumif
This is involving concatenating several text lines when they show a matching reference. E.G if column a shows "LT_001", then concatenate the comments of all with same referance. I had intended to copy out the formula used, and adjust it to fit my situation, but if I copy the formula into VBA it does not allow me to run the function.
I have the same problem with most VBA code taken from the internet and can't figure out what I should be doing? I have literally copied the formula as is, bar changing "A7" to "A2". As I am trying to adjust the formula to fit, for the moment my workbook has example data in columns A, B, and C, and a consolidated list of column A in Column G.
This is the function I have copied from the page:
Public Function Test(TruckNo) As String
Dim EndRow As Long
Dim NN As String
Dim x As Long
EndRow = Range("A7").End(xlDown).Row
For x = 7 To EndRow
If Cells(x, 1).Value = TruckNo Then NN = NN & Cells(x, 2).Value _
& " : " & Cells(x, 3).Value & Chr(10)
Next x
NN = Left(NN, Len(NN) - 1)
Test = NN
End Function
Do I need to change some of this text in order to make this run?
As is blindingly obvious, I have no idea what I am doing in VBA, so any help on why I can't get things to work is hugely appreciated.
Thank you,
Larisa
Bookmarks