Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 13
Default User-defined concatenation

Hi. I'm looking to be able to concatenate four items but enable the
user to define the order in which the items are concatenated. The
concatenation will be a 'title' in a log, and users have titled things
manually and differently for a long time, so I would like to make the
programming update I'm trying to make flexible enough to enable users
to continue using their own personal logs.

I currently have two columns, Category and Number. My thought is to
insert an 'Order' column in column A to allow the user to define the
order of concatenation.

For example, user Bob has his four categories order defined as
Catalog#-INV-CMPL-Notes, as shown below.

Order Category Number
1 Catalog# 5100
2 INV 87500
3 CMPL 87000
4 Notes Red (bush)

Title: 5100-87500-87000-Red (bush)

But user Sue has her four catergores order defined as
INV-CMPL-Catago#-Notes, as shown below.

Order Category Number
3 Catalog# 5100
1 INV 87500
2 CMPL 87000
4 Notes Red (bush)

Title: 87500-87000-5100-Red (bush)

What might be the formula I could use in the cell next to Title:?
I've thought I might need some sort of Indirect, but I haven't been
able to think how to apply this. And I haven't been able to find
anything in my search in this group or on the internet. I'd greatly
appreciate any thoughts and assistance. Thanks!

Frank
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,872
Default User-defined concatenation

Hi Frank,

Am Sat, 27 Jun 2015 14:54:47 -0400 schrieb :

Order Category Number
1 Catalog# 5100
2 INV 87500
3 CMPL 87000
4 Notes Red (bush)

Title: 5100-87500-87000-Red (bush)

But user Sue has her four catergores order defined as
INV-CMPL-Catago#-Notes, as shown below.

Order Category Number
3 Catalog# 5100
1 INV 87500
2 CMPL 87000
4 Notes Red (bush)

Title: 87500-87000-5100-Red (bush)


look he
https://onedrive.live.com/redir?resi...=folder%2cxlsm
for "Concatenate" and download the workbook because macros are disabled
in OneDrive.
I wrote a UDF for your problem.


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 13
Default User-defined concatenation

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?

Honestly, Claus, my mind is a blur with all the possibilities now!
Things I wondered how to do before. I know I still have a LOT to
learn, but this is an exceptional opening to something new for me.
Thank you again for your help!

Best regards,

Frank

On Sat, 27 Jun 2015 21:19:50 +0200, Claus Busch
wrote:

Hi Frank,

Am Sat, 27 Jun 2015 14:54:47 -0400 schrieb :

Order Category Number
1 Catalog# 5100
2 INV 87500
3 CMPL 87000
4 Notes Red (bush)

Title: 5100-87500-87000-Red (bush)

But user Sue has her four catergores order defined as
INV-CMPL-Catago#-Notes, as shown below.

Order Category Number
3 Catalog# 5100
1 INV 87500
2 CMPL 87000
4 Notes Red (bush)

Title: 87500-87000-5100-Red (bush)


look he
https://onedrive.live.com/redir?resi...=folder%2cxlsm
for "Concatenate" and download the workbook because macros are disabled
in OneDrive.
I wrote a UDF for your problem.


Regards
Claus B.

  #5   Report Post  
Posted to microsoft.public.excel.misc
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.



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,872
Default User-defined concatenation

Hi Frank,

Am Tue, 30 Jun 2015 07:36:24 -0400 schrieb Phrank:

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?


if a block always has 4 filled rows you only have to change
myRng.Rows.Count to 4:

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

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

and call the function into the sheet then with:
=Title(A1:C5)


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compile error: User-defined type not defined Ayo Excel Programming 3 April 23rd 09 07:42 PM
"User-defined type not defined" message in Excel RW1946 Excel Discussion (Misc queries) 0 August 31st 05 12:14 PM
Workspace faux user-defined type not defined Chris S[_2_] Excel Programming 3 November 11th 04 05:51 PM
User-defined data type; Error: Only User-defined types... tiger_PRM Excel Programming 1 July 18th 04 03:32 PM
Word.Document - user defined type not defined jowatkins[_7_] Excel Programming 0 January 20th 04 08:46 AM


All times are GMT +1. The time now is 10:34 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"