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
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