ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   two word last names (https://www.excelbanter.com/excel-programming/324847-two-word-last-names.html)

David Bateman

two word last names
 
I am importing data delimited, with tab and space selected if counta = 12
then everything is fine if counta = 13 then I have people with two word last
names. When this is the case how would I programmatically combine the names
in columns c, d to reflect this?
Thank you in advance.

db



gmunro

two word last names
 
If I am understanding you, I think you can do this with a formula
If C1 = Abdul
and D1 = Jabar
in cell E1, enter =C1&"-"&D1
E1's value will be "Abdul-Jabar"
Then just copy and paste as values.
(The "-" is to hyphenate the name.)

Does this help?


david mcritchie

two word last names
 
Hi David,
If I am guessing correctly you want to combine Column B & C
together if there is a value in Column M (col 13), and then
delete the cell in Column C in such rows shifting the remaining
cells left. Suggest you try this on a copy of your worksheet.

Sub Combine_BandC_if_M_notempty()
'David McRitchie, 2005-03-08 programming
'assumes since this came from elsewhere that Column M
' is either empty or has a constant (not a formula)
' an empty string i.e. single quote would not be empty
Dim cell As Range, rng As Range, i As Long
On Error Resume Next
Set rng = Range("M:M").SpecialCells(xlConstants)
If rng Is Nothing Then Exit Sub
On Error GoTo 0
For Each cell In rng
Cells(cell.row, 2) = ActiveSheet.Cells(cell.row, 2) _
& " " & Cells(cell.row, 3)
Cells(cell.row, 3).Delete Shift:=xlToLeft
Next cell
End Sub
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"David Bateman" wrote in message ...
I am importing data delimited, with tab and space selected if counta = 12
then everything is fine if counta = 13 then I have people with two word last
names. When this is the case how would I programmatically combine the names
in columns c, d to reflect this?
Thank you in advance.

db






All times are GMT +1. The time now is 10:48 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com