+ Reply to Thread
Results 1 to 13 of 13

Need a fast way to combine - pre defined content via ALIASES / IDENTIFIERS.

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    08-17-2010
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    127

    Need a fast way to combine - pre defined content via ALIASES / IDENTIFIERS.

    A1 = "barracks lvl 1"
    A2 = "barracks lvl 2"
    A3 = "My friend Johny"
    A4 = "has to build"

    Anywhere i need to type Jo,bld,rax2
    and get =A3&A4&A2

    Why?
    Its easier to remember what i need by identifying it somehow with aliases than remembering each cell address i need. and moving around to find it, and get the address or copy it.

    What i can think of is a shitload of nested ifs. But there probably is a simple way of doing this...
    Last edited by Polymorpher; 08-01-2014 at 09:34 AM. Reason: Good search name - solved

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Need a fast way to combine - pre defined content.

    Why not use named ranges?
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Forum Contributor
    Join Date
    08-17-2010
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    127

    Re: Need a fast way to combine - pre defined content.

    @ Olly
    Because i don't know what they are and how to use them (: Wouldn't be asking if i knew (:

    @newdoverman
    I'll check that out and get back to ya.
    Last edited by Polymorpher; 07-31-2014 at 09:56 AM.

  4. #4
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Need a fast way to combine - pre defined content.

    Go to the Name Manager, click on new and assign a name. I used ABC. In the formula field enter:

    Formula: copy to clipboard
    =Sheet1!$A$1&Sheet1!$A$2&Sheet1!$A$3&Sheet1!$A$4


    Now when you want to use this click in the cell type =ABC enter.
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

  5. #5
    Forum Contributor
    Join Date
    08-17-2010
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    127

    Re: Need a fast way to combine - pre defined content.

    Allrighty i mapped a range from a22 to a32 named ABC.

    Any way i can reference the third cell from that range?

    like =ABC3 ?

    P.S.

    Google pointed out to =INDEX(ABC, 3)

    But thats kind of bulky, INDEX(ABC,3)&INDEX(ABC,2)&INDEX(JAZ,15)
    Last edited by Polymorpher; 07-31-2014 at 10:50 AM.

  6. #6
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Need a fast way to combine - pre defined content.

    Try assigning Named Ranges as follows:

    A1 = "barracks lvl 1 " - Name as brax1
    A2 = "barracks lvl 2 " - Name as brax2
    A3 = "My friend Johny " - Name as jo
    A4 = "has to build " - Name as bld

    Now you just enter:
    Formula: copy to clipboard
    =jo&bld&brax2

  7. #7
    Forum Contributor
    Join Date
    08-17-2010
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    127

    Re: Need a fast way to combine - pre defined content.

    @ Olly I googled that out. But then i have to map out 3000 things instead of 100. Its easier for me to map out Brax1 to 15 as a whole range and return specific cell from it - than mapping every cell i need to return.

    I'll probably do that if there is no other alternative. Or perhaps turn to the VBA gurus.

  8. #8
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Need a fast way to combine - pre defined content.

    It seems that the parameters are changing for this problem.

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

  9. #9
    Forum Contributor
    Join Date
    08-17-2010
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    127

    Re: Need a fast way to combine - pre defined content.

    Example.xlsx

    I didn't know how to do this at all so, i'm figuring it out as i go.

  10. #10
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Need a fast way to combine - pre defined content.

    How's your VBA?!

    Put this code in the worksheet module:
    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim c As Range, stInput() As String, stOutput() As String
    Dim stRangeName As String, iRangeIndex As Integer
    Dim i As Integer, j As Integer
    
    On Error GoTo ErrCatch
    Application.EnableEvents = False
    For Each c In Target
        If c.Value = "" Or c.Column = 1 Then Exit Sub
        stInput() = Split(c.Value, ";")
        ReDim stOutput(UBound(stInput))
        For i = LBound(stInput) To UBound(stInput)
            stRangeName = Left(stInput(i), FirstNumber(stInput(i)))
            iRangeIndex = CInt(Right(stInput(i), Len(stInput(i)) - FirstNumber(stInput(i))))
            stOutput(i) = Range(stRangeName).Cells(iRangeIndex).Value
        Next i
        c.Value = Join(stOutput, "")
    Next c
    Application.EnableEvents = True
    Exit Sub
    ErrCatch:
        Debug.Print "Error: " & Err.Number & " - " & Err.Description
        Application.EnableEvents = True
    End Sub
    
    Function FirstNumber(ByVal s As String)
    Dim i As Integer
    For i = 1 To Len(s)
        If IsNumeric(Mid(s, i, 1)) Then
            FirstNumber = i - 1
            Exit Function
        End If
    Next i
    End Function
    Now, just type in the range names / indexes you want, in a cell. No = sign first. For example, enter:
    Formula: copy to clipboard
    PLACES3;MUSIC5;FRUIT2;ALC8;SOFT7

    and it will automatically change to:
    Formula: copy to clipboard
    BAR3;JAZ5;APPLE2;VODKA8;TONIC7;

  11. #11
    Forum Contributor
    Join Date
    08-17-2010
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    127

    Re: Need a fast way to combine - pre defined content.

    Awesome, I'll try it out in the morning when I'm not barely keeping me eyes opened.

  12. #12
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Need a fast way to combine - pre defined content.

    Be aware, it's very rough coding - there's no error handling built in, and it immediately overwrites cell contents on entry, so handle with care! If you think this approach will work, though, then we can work on making it a bit more user friendly and efficient.

  13. #13
    Forum Contributor
    Join Date
    08-17-2010
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    127

    Re: Need a fast way to combine - pre defined content.

    @ Olly it crashed.

    Anyhow i think its prudent to actually call the function instead of having it check every cell you use or have.

    Bernie Deitrick came up with something quite efficient over at the VBA forum:

    =StrOffset("namerange 3 namerange 1 namerange 5",1)

    Function StrOffset(strAdd As String, iOff As Integer) As String
        Dim V As Variant
        Dim i As Integer
        
        V = Split(strAdd, " ")
        For i = LBound(V) To UBound(V) Step 2
            StrOffset = Trim(StrOffset) & " " & Range(V(i)).Cells(CInt(V(i + 1))).Offset(0, iOff).Value
        Next i
                    
    End Function
    Theres also an option with =SUM but I don't need it.

    You can check it out at:
    http://www.excelforum.com/excel-prog...th-offset.html

    Thank you all. - Solved.
    Last edited by Polymorpher; 08-01-2014 at 09:33 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Combine cell content into an html code?
    By jake5 in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 06-03-2013, 01:40 AM
  2. [SOLVED] How to combine VLookup and Defined names??
    By Dubrock in forum Excel General
    Replies: 14
    Last Post: 06-04-2012, 10:04 AM
  3. Is it possible to combine 2 User Defined Types?
    By tom.hogan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-11-2012, 09:08 AM
  4. Combine sheets and react on content
    By KingManon in forum Excel General
    Replies: 3
    Last Post: 10-19-2010, 03:09 AM
  5. User Defined Object help fast
    By reddog9069 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-27-2005, 10:40 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1