Merging Cell Data

kluitna

Board Regular
Joined
Mar 10, 2002
Messages
75
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.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
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
 
Upvote 0
A easy way to merge data is with the comand ( Concatenate ). Which will merge two or more fields.
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,395
Messages
6,119,265
Members
448,881
Latest member
Faxgirl

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top