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
Last edited by LTurnbull; 04-15-2011 at 10:51 AM.
It would help to see your workbook/data
It's a User Defined Function (UDF) so you call it in a cell like a standard Excel function, or in a VBA macro.
Regards
:: blushes ::
That really was a bit foolish. Of course it won't run, it's not a macro.
Thank you very much. It works just as it should.
No problem, we all make mistakes.
It's more foolish not to ask when you need help ... and I bet you won't make that mistake again in a rush :-)
Regards
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks