Thanks Thanks:  0
Likes Likes:  0
Results 1 to 4 of 4

Thread: Merging Cell Data

  1. #1
    Board Regular
    Join Date
    Mar 2002
    Posts
    75
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I looked through the search and could not find excatly whatI was looking for here.

    What I am trying to do is merge data from 2 different cells into one cell. I have tried to use the merge cell command in excel but it drops the data from the second cell or cells. Kind of defeats the purpose.

    I tried to record a macro to do this but it uses the specific cell data, and my prblem is each cell has different data that I want to merge. I know it can be done this way, just need to use the right variables. Anyone out there have the code out there for this. Any help would be much appreciated.

  2. #2
    Board Regular
    Join Date
    Mar 2002
    Posts
    75
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Here is the answer to my own question, For anyone who wondered how it could be done here is one one way

    Merge cell Data()
    '
    Dim CellData As String
    Dim CellData1 As String
    Sheets(1).Cells(1, 2).Select
    CellData = Sheets(1).Cells(1, 2)
    strfile = CellData
    ActiveCell.FormulaR1C1 = strfile
    Sheets(1).Cells(1, 1).Select
    CellData1 = Sheets(1).Cells(1, 1)
    strfile1 = CellData1
    ActiveCell.FormulaR1C1 = CellData1 & CellData
    End Sub

  3. #3
    Board Regular
    Join Date
    Mar 2002
    Location
    Arkansas
    Posts
    358
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    A easy way to merge data is with the comand ( Concatenate ). Which will merge two or more fields.

  4. #4
    Board Regular
    Join Date
    Mar 2002
    Posts
    75
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Here is the final code I came up with that works quite well. Only one nit picky problem. Is there way to put s space between the merged data?

    Sub merge_cell_data()
    '
    ' Macro1 Macro
    ' Macro recorded 3/21/2002 by ctemp
    '

    '
    Dim CellData As String
    Dim CellData1 As String
    Dim MergedData As String
    For i = 0 To 500
    CellData = Sheets(1).Cells(1 + i, 2)
    CellData1 = Sheets(1).Cells(1 + i, 1)
    MergedData = CellData1 & CellData
    If CellData = blank Then End
    Sheets(1).Cells(1 + i, 6).Select
    ActiveCell.FormulaR1C1 = MergedData
    Next
    End Sub

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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