+ Reply to Thread
Results 1 to 3 of 3

Macro to merge

  1. #1
    Registered User
    Join Date
    05-20-2012
    Location
    Taiwan
    MS-Off Ver
    Office 365
    Posts
    47

    Macro to merge

    Hi,

    I need to enhance this. The destination cell should have a commar separating each cell merged with no spaces.

    For e.g.

    Cells:
    A1: APPLE
    A2: ORANGE
    A3: MANGO


    Results (to merge A1:A3) is APPLE,ORANGE,MANGO (with commar and no spaces)

    Would anyone be able to help?

    Thank you.


    PHP Code: 
    Sub JoinCells()

    Set xJoinRange Application.InputBox(prompt:="Highlight source cells to merge"Type:=8)
    xSource 0
    xSource 
    xJoinRange.Rows.Count
    xType 
    "rows"
    If xSource 1 Then
        xSource 
    xJoinRange.Columns.Count
        xType 
    "columns"
    End If
    Set xDestination Application.InputBox(prompt:="Highlight destination cell"Type:=8)
    If 
    xType "rows" Then
        temp 
    xJoinRange.Rows(1).Value
        
    For 2 To xSource
            temp 
    temp " " xJoinRange.Rows(i).Value
        Next i
    Else
        
    temp xJoinRange.Columns(1).Value
        
    For 2 To xSource
            temp 
    temp " " xJoinRange.Columns(i).Value
        Next i
    End 
    If

    xDestination.Value temp

    End Sub 

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Macro to merge

    temp = temp & "," & xJoinRange.Rows(i).Value

    something like that??????????

    Hope this helps

    Sometimes its best to start at the beginning and learn VBA & Excel.

    Please dont ask me to do your work for you, I learnt from Reading books, Recording, F1 and Google and like having all of this knowledge in my head for the next time i wish to do it, or wish to tweak it.
    Available for remote consultancy work PM me

  3. #3
    Registered User
    Join Date
    05-20-2012
    Location
    Taiwan
    MS-Off Ver
    Office 365
    Posts
    47

    Re: Macro to merge

    Hi Nathansav,

    Thanks, but unfortunately not. It does not work.

+ 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. [SOLVED] Macro to merge duplicate rows unique values - current macro not working
    By aimeecrystalaid in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-06-2013, 03:42 PM
  2. how do i merge two macro into one ?
    By accountant. in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-31-2011, 12:31 PM
  3. Can't merge my mail macro and signature macro
    By JohannesEngelbert in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-14-2010, 01:54 PM
  4. Macro to run mail merge?
    By carlosbourn in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-15-2008, 08:41 AM
  5. macro for mail merge
    By princepp in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-02-2008, 08:25 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