MergeToOneCell

G

Guest

Hi, J.E.
In testing out your code, I kept getting an object missing error and it
failing on the IF fRng Is Nothing condition. The only way I can get it to
work is by commenting out the If codition. Then it works fine if a
selection is made on the spreadsheet.
BTW! Thanks for all our help! I got the codes working and I was able to
attache it to the tool bar button simply by attaching a macro code of the
non, CCT button to the custom button I installed.
Jeff

Public Sub MergeToOneCell()
'J.E. McGimpsey, http://www.mcgimpsey.com/excel/mergedata.html
Const sDelim As String = ", "
Dim rCell As Range
Dim sMergeStr As String
' If rRng Is Nothing Then
Set rRng = Selection
With rRng
For Each rCell In .Cells
sMergeStr = sMergeStr & sDelim & rCell.Text
Next rCell
Application.DisplayAlerts = False
.Merge Across:=False
Application.DisplayAlerts = True
.Item(1).Value = Mid(sMergeStr, 1 - (sDelim <> ""))
End With
End Sub
~~~~~~~~~~~~
Jefferis Peterson, Pres.
Web Design and Marketing
http://www.PetersonSales.com
 
J

JE McGimpsey

Jefferis NoSpamme said:
Hi, J.E.
In testing out your code, I kept getting an object missing error and it
failing on the IF fRng Is Nothing condition. The only way I can get it to
work is by commenting out the If codition. Then it works fine if a
selection is made on the spreadsheet.
BTW! Thanks for all our help! I got the codes working and I was able to
attache it to the tool bar button simply by attaching a macro code of the
non, CCT button to the custom button I installed.
Jeff

I revamped my site today. Take a look at

http://www.mcgimpsey.com/excel/mergedata.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top