Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Name parsing formula..

I'm trying to normalize a database and I've imported a single field with
names into excel and split them into multiple columns. The biggest problem I
have now is clean up. The majority of which seems to be users with no middle
name/initial where the lastname got pulled into the middle name column.

Example

first middle last suffix
John A Doe Sr.
Mary Doe

In this case the first line imports fine, but the second line Mary gets put
into the first name field, but Doe gets put into Middle instead of last.
I've isolated these and in all cases, if there is nothing in the last name
field and there is something in the middle name field, I want to replace the
value in Last (nothing) with the value in middle and delete middle. This is
the macro I've written so far, but I haven't done any excel macro's in over
a year, so I'm way rusty and I only have excel 97 to work with at the
moment.

Sub MoveLastName()

Dim MyRange As Range, cl As Range
Set MyRange = Range("c1", Range("c64000").End(xlUp))
For Each cl In MyRange
If IsEmpty(cl) And Not IsEmpty(cl.Offset(0, -1)) Then
Debug.Print cl.Row
With cl.Offset(0, -1)
Debug.Print cl
cl.Value = .Value
'.Delete
End With
End If
Next
End Sub

When I run this, I get goofy results that I can't quite place. I do get the
middle name in the lastname field, but then the middle name field gets data
in it from other odd places in the spreadsheet. What is wrong with my
function? Also, how can I debug.print a range object so I can see where the
data it is using is comming from?

Thanks

Matt


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Name parsing formula..

see if this helps
http://www.cpearson.com/excel/FirstLast.htm

--
Don Guillett
SalesAid Software

"Matt Williamson" wrote in message
...
I'm trying to normalize a database and I've imported a single field with
names into excel and split them into multiple columns. The biggest problem

I
have now is clean up. The majority of which seems to be users with no

middle
name/initial where the lastname got pulled into the middle name column.

Example

first middle last suffix
John A Doe Sr.
Mary Doe

In this case the first line imports fine, but the second line Mary gets

put
into the first name field, but Doe gets put into Middle instead of last.
I've isolated these and in all cases, if there is nothing in the last name
field and there is something in the middle name field, I want to replace

the
value in Last (nothing) with the value in middle and delete middle. This

is
the macro I've written so far, but I haven't done any excel macro's in

over
a year, so I'm way rusty and I only have excel 97 to work with at the
moment.

Sub MoveLastName()

Dim MyRange As Range, cl As Range
Set MyRange = Range("c1", Range("c64000").End(xlUp))
For Each cl In MyRange
If IsEmpty(cl) And Not IsEmpty(cl.Offset(0, -1)) Then
Debug.Print cl.Row
With cl.Offset(0, -1)
Debug.Print cl
cl.Value = .Value
'.Delete
End With
End If
Next
End Sub

When I run this, I get goofy results that I can't quite place. I do get

the
middle name in the lastname field, but then the middle name field gets

data
in it from other odd places in the spreadsheet. What is wrong with my
function? Also, how can I debug.print a range object so I can see where

the
data it is using is comming from?

Thanks

Matt




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Name parsing formula..

Thanks Don..

Unfortunately, the names don't follow the patterns that Chip's formulas
require, so other than giving me an interesting code example, this doesn't
help my immediate needs. I don't see any good way to modify it to meet them
either.

Matt


"Don Guillett" wrote in message
...
see if this helps
http://www.cpearson.com/excel/FirstLast.htm

--
Don Guillett
SalesAid Software

"Matt Williamson" wrote in message
...
I'm trying to normalize a database and I've imported a single field with
names into excel and split them into multiple columns. The biggest

problem
I
have now is clean up. The majority of which seems to be users with no

middle
name/initial where the lastname got pulled into the middle name column.

Example

first middle last suffix
John A Doe Sr.
Mary Doe

In this case the first line imports fine, but the second line Mary gets

put
into the first name field, but Doe gets put into Middle instead of last.
I've isolated these and in all cases, if there is nothing in the last

name
field and there is something in the middle name field, I want to replace

the
value in Last (nothing) with the value in middle and delete middle. This

is
the macro I've written so far, but I haven't done any excel macro's in

over
a year, so I'm way rusty and I only have excel 97 to work with at the
moment.

Sub MoveLastName()

Dim MyRange As Range, cl As Range
Set MyRange = Range("c1", Range("c64000").End(xlUp))
For Each cl In MyRange
If IsEmpty(cl) And Not IsEmpty(cl.Offset(0, -1)) Then
Debug.Print cl.Row
With cl.Offset(0, -1)
Debug.Print cl
cl.Value = .Value
'.Delete
End With
End If
Next
End Sub

When I run this, I get goofy results that I can't quite place. I do get

the
middle name in the lastname field, but then the middle name field gets

data
in it from other odd places in the spreadsheet. What is wrong with my
function? Also, how can I debug.print a range object so I can see where

the
data it is using is comming from?

Thanks

Matt






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Name parsing formula..

Sub ProcNames()
Dim MyRange As Range, cl As Range
Set MyRange = Range("c1", Range("c64000").End(xlUp))
For Each cl In MyRange
If IsEmpty(cl) And Not IsEmpty(cl.Offset(0, -1)) Then
With cl.Offset(0, -1)
cl.Value = .Value
.clearContents
End With
End If
Next
End Sub

--
Regards,
Tom Ogilvy


"Matt Williamson" wrote in message
...
I'm trying to normalize a database and I've imported a single field with
names into excel and split them into multiple columns. The biggest problem

I
have now is clean up. The majority of which seems to be users with no

middle
name/initial where the lastname got pulled into the middle name column.

Example

first middle last suffix
John A Doe Sr.
Mary Doe

In this case the first line imports fine, but the second line Mary gets

put
into the first name field, but Doe gets put into Middle instead of last.
I've isolated these and in all cases, if there is nothing in the last name
field and there is something in the middle name field, I want to replace

the
value in Last (nothing) with the value in middle and delete middle. This

is
the macro I've written so far, but I haven't done any excel macro's in

over
a year, so I'm way rusty and I only have excel 97 to work with at the
moment.

Sub MoveLastName()

Dim MyRange As Range, cl As Range
Set MyRange = Range("c1", Range("c64000").End(xlUp))
For Each cl In MyRange
If IsEmpty(cl) And Not IsEmpty(cl.Offset(0, -1)) Then
Debug.Print cl.Row
With cl.Offset(0, -1)
Debug.Print cl
cl.Value = .Value
'.Delete
End With
End If
Next
End Sub

When I run this, I get goofy results that I can't quite place. I do get

the
middle name in the lastname field, but then the middle name field gets

data
in it from other odd places in the spreadsheet. What is wrong with my
function? Also, how can I debug.print a range object so I can see where

the
data it is using is comming from?

Thanks

Matt




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Name parsing formula..

Hi Matt

If you have Outlook on your system: Dick Kusleika wrote a great little
routine that uses Outlook's name parser, remote controlled from Excel.
http://www.dicks-blog.com/archives/2...-with-outlook/

HTH. Best wishes Harald

"Matt Williamson" skrev i melding
...
I'm trying to normalize a database and I've imported a single field with
names into excel and split them into multiple columns. The biggest problem

I
have now is clean up. The majority of which seems to be users with no

middle
name/initial where the lastname got pulled into the middle name column.

Example

first middle last suffix
John A Doe Sr.
Mary Doe

In this case the first line imports fine, but the second line Mary gets

put
into the first name field, but Doe gets put into Middle instead of last.
I've isolated these and in all cases, if there is nothing in the last name
field and there is something in the middle name field, I want to replace

the
value in Last (nothing) with the value in middle and delete middle. This

is
the macro I've written so far, but I haven't done any excel macro's in

over
a year, so I'm way rusty and I only have excel 97 to work with at the
moment.

Sub MoveLastName()

Dim MyRange As Range, cl As Range
Set MyRange = Range("c1", Range("c64000").End(xlUp))
For Each cl In MyRange
If IsEmpty(cl) And Not IsEmpty(cl.Offset(0, -1)) Then
Debug.Print cl.Row
With cl.Offset(0, -1)
Debug.Print cl
cl.Value = .Value
'.Delete
End With
End If
Next
End Sub

When I run this, I get goofy results that I can't quite place. I do get

the
middle name in the lastname field, but then the middle name field gets

data
in it from other odd places in the spreadsheet. What is wrong with my
function? Also, how can I debug.print a range object so I can see where

the
data it is using is comming from?

Thanks

Matt






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Name parsing formula..

I was so close <g

Thanks Tom

"Tom Ogilvy" wrote in message
...
Sub ProcNames()
Dim MyRange As Range, cl As Range
Set MyRange = Range("c1", Range("c64000").End(xlUp))
For Each cl In MyRange
If IsEmpty(cl) And Not IsEmpty(cl.Offset(0, -1)) Then
With cl.Offset(0, -1)
cl.Value = .Value
.clearContents
End With
End If
Next
End Sub

--
Regards,
Tom Ogilvy


"Matt Williamson" wrote in message
...
I'm trying to normalize a database and I've imported a single field with
names into excel and split them into multiple columns. The biggest

problem
I
have now is clean up. The majority of which seems to be users with no

middle
name/initial where the lastname got pulled into the middle name column.

Example

first middle last suffix
John A Doe Sr.
Mary Doe

In this case the first line imports fine, but the second line Mary gets

put
into the first name field, but Doe gets put into Middle instead of last.
I've isolated these and in all cases, if there is nothing in the last

name
field and there is something in the middle name field, I want to replace

the
value in Last (nothing) with the value in middle and delete middle. This

is
the macro I've written so far, but I haven't done any excel macro's in

over
a year, so I'm way rusty and I only have excel 97 to work with at the
moment.

Sub MoveLastName()

Dim MyRange As Range, cl As Range
Set MyRange = Range("c1", Range("c64000").End(xlUp))
For Each cl In MyRange
If IsEmpty(cl) And Not IsEmpty(cl.Offset(0, -1)) Then
Debug.Print cl.Row
With cl.Offset(0, -1)
Debug.Print cl
cl.Value = .Value
'.Delete
End With
End If
Next
End Sub

When I run this, I get goofy results that I can't quite place. I do get

the
middle name in the lastname field, but then the middle name field gets

data
in it from other odd places in the spreadsheet. What is wrong with my
function? Also, how can I debug.print a range object so I can see where

the
data it is using is comming from?

Thanks

Matt






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Name parsing formula..

Good stuff there Harold.
I actually ended up finding a routine in the NG's that Nick Hodge wrote. I
had to add a couple more scenarios to it for the goofy data I'm working
with, but overall, it works great.

I'll compare it against what this Outlook code gives me on the same dataset.

Thanks

"Harald Staff" wrote in message
...
Hi Matt

If you have Outlook on your system: Dick Kusleika wrote a great little
routine that uses Outlook's name parser, remote controlled from Excel.
http://www.dicks-blog.com/archives/2...-with-outlook/

HTH. Best wishes Harald

"Matt Williamson" skrev i melding
...
I'm trying to normalize a database and I've imported a single field with
names into excel and split them into multiple columns. The biggest

problem
I
have now is clean up. The majority of which seems to be users with no

middle
name/initial where the lastname got pulled into the middle name column.

Example

first middle last suffix
John A Doe Sr.
Mary Doe

In this case the first line imports fine, but the second line Mary gets

put
into the first name field, but Doe gets put into Middle instead of last.
I've isolated these and in all cases, if there is nothing in the last

name
field and there is something in the middle name field, I want to replace

the
value in Last (nothing) with the value in middle and delete middle. This

is
the macro I've written so far, but I haven't done any excel macro's in

over
a year, so I'm way rusty and I only have excel 97 to work with at the
moment.

Sub MoveLastName()

Dim MyRange As Range, cl As Range
Set MyRange = Range("c1", Range("c64000").End(xlUp))
For Each cl In MyRange
If IsEmpty(cl) And Not IsEmpty(cl.Offset(0, -1)) Then
Debug.Print cl.Row
With cl.Offset(0, -1)
Debug.Print cl
cl.Value = .Value
'.Delete
End With
End If
Next
End Sub

When I run this, I get goofy results that I can't quite place. I do get

the
middle name in the lastname field, but then the middle name field gets

data
in it from other odd places in the spreadsheet. What is wrong with my
function? Also, how can I debug.print a range object so I can see where

the
data it is using is comming from?

Thanks

Matt






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formula/Function for parsing data Nadine Excel Worksheet Functions 5 April 1st 10 08:46 PM
parsing a formula... Dave F[_2_] Excel Discussion (Misc queries) 3 August 25th 07 12:20 AM
Parsing Saxman[_2_] Excel Discussion (Misc queries) 3 July 30th 07 04:36 PM
Instead of Parsing Krish Excel Discussion (Misc queries) 1 November 4th 06 08:32 PM
Parsing Data w/ a Formula (another question) carl Excel Worksheet Functions 2 December 3rd 04 06:51 PM


All times are GMT +1. The time now is 09:03 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"