View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Phrank Phrank is offline
external usenet poster
 
Posts: 153
Default User-defined concatenation

Ah, I see. That makes sense. I've run into a (hopefully minor) snag
with implementation, though. There's a blank line between rows 3 and
4, as shown below (blocks off groups of info (not my formatting, but I
have to work with it). Would I just account for a blank cell in A(i)
and have the loop press on, like below? Thanks Claus!

Frank

1 Catalog# 5100
2 INV 87500
3 CMPL 87000

4 Notes Red (bush)


Function Title(myRng As Range) As String
Dim i As Long, myStr As String

For i = 1 To myRng.Rows.Count
If Range("A"&i).value = "" Then Next i

myStr = myStr & "-" & _
Evaluate("=VLOOKUP(" & i & "," & myRng.Address & ",3,0)")
Next
Title = Mid(myStr, 2)
End Function


On Sun, 28 Jun 2015 09:46:59 +0200, Claus Busch
wrote:

Hi Frank,

Am Sun, 28 Jun 2015 00:40:56 -0400 schrieb :

That is AMAZING! Yet again, another powerful piece of Excel
functionalilty that I simply wasn't aware of. I understand all of the
UDF except the very last line (Title = Mid(myStr, 2)). I understood
how the UDF was building the concatenation via the loop, and I
expected that result to be Title. How does this last line of code
after the loop fit in?


the string is concatenated with:
myStr = myStr & "-" & _
Evaluate("=VLOOKUP(" & i & "," & myRng.Address & ",3,0)")

This causes that a hyphen is the first character of the string.
Therefore the Title begins with character 2:
Title = Mid(myStr, 2)


Regards
Claus B.