Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 440
Default splitting names from one cell to two cells

In cells in column E, I have names (could be John Doe, Dr John Stephen Henry
Doe, could be a company name) which are seperated by the character "v" which
indicates parties on one side versus parties on the other side.
I only need to split the data in cells in E which will be dictated by
ActiveCell.Row
How can I split the data in a cell in E into everything to the left of the
"v" to sheet2, lastrow + 1 (I've already got that bit working) col C, and
everything after the "v" to col E on that same sheet?

The line below currently copies all the data from a cell in wbS, col E to
the other col C on the other sheet. I need to split the data to C and E on
the new sheet (col D will have the v in it).
..Range("C" & lngNewRow).Value = wbS.Range("E" & lngRowNo)

I hope that makes sense!
--
Traa Dy Liooar

Jock
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default splitting names from one cell to two cells

jock,

I think the issue with doing this, i.e. splitting a cells contents either
side of a "v", is what happens if there's another v in the cell (Dr, Vernon
somename) for example so this may be more difficult than it seems.

However, here's 2 lines of code that split the active cell at the 'v' to the
cells either side


ActiveCell.Offset(, -1).Value = Left(ActiveCell.Value, InStr(1,
ActiveCell.Value, "v", vbTextCompare) - 1)


ActiveCell.Offset(, 1).Value = Mid(ActiveCell.Value, InStr(1,
ActiveCell.Value, "v", vbTextCompare) + 1)

If you post more of your code and some sample data then perhaps it can be
made more specific.
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Jock" wrote:

In cells in column E, I have names (could be John Doe, Dr John Stephen Henry
Doe, could be a company name) which are seperated by the character "v" which
indicates parties on one side versus parties on the other side.
I only need to split the data in cells in E which will be dictated by
ActiveCell.Row
How can I split the data in a cell in E into everything to the left of the
"v" to sheet2, lastrow + 1 (I've already got that bit working) col C, and
everything after the "v" to col E on that same sheet?

The line below currently copies all the data from a cell in wbS, col E to
the other col C on the other sheet. I need to split the data to C and E on
the new sheet (col D will have the v in it).
.Range("C" & lngNewRow).Value = wbS.Range("E" & lngRowNo)

I hope that makes sense!
--
Traa Dy Liooar

Jock

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default splitting names from one cell to two cells

Try

Dim strData As String

strData = ActiveCell.Text
strData = "firstdata v seconddata"
If InStr(1, strData, " v ", vbBinaryCompare) Then
MsgBox Trim(Left(strData, InStr(1, strData, " v ", vbBinaryCompare)))
MsgBox Trim(Mid(strData, InStr(1, strData, " v ", vbBinaryCompare) + 3))
End If


--
Jacob (MVP - Excel)


"Jock" wrote:

In cells in column E, I have names (could be John Doe, Dr John Stephen Henry
Doe, could be a company name) which are seperated by the character "v" which
indicates parties on one side versus parties on the other side.
I only need to split the data in cells in E which will be dictated by
ActiveCell.Row
How can I split the data in a cell in E into everything to the left of the
"v" to sheet2, lastrow + 1 (I've already got that bit working) col C, and
everything after the "v" to col E on that same sheet?

The line below currently copies all the data from a cell in wbS, col E to
the other col C on the other sheet. I need to split the data to C and E on
the new sheet (col D will have the v in it).
.Range("C" & lngNewRow).Value = wbS.Range("E" & lngRowNo)

I hope that makes sense!
--
Traa Dy Liooar

Jock

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default splitting names from one cell to two cells

Hello Jock,

A simple way to achieve name separation in Excel 2007 consists of the
following steps:
Leave column F free
mark your list of names to be separated
data
text to column
delimited
Convert text to Column Wizard delimiter: other, v (unmark others)
Column E will have all data up to "v", Column F the rest.

best regards

Gabor Sebo
------------------------------------------------------------------------------------------------------------------------------------------------------------------


"Jock" wrote in message
...
In cells in column E, I have names (could be John Doe, Dr John Stephen
Henry
Doe, could be a company name) which are seperated by the character "v"
which
indicates parties on one side versus parties on the other side.
I only need to split the data in cells in E which will be dictated by
ActiveCell.Row
How can I split the data in a cell in E into everything to the left of the
"v" to sheet2, lastrow + 1 (I've already got that bit working) col C, and
everything after the "v" to col E on that same sheet?

The line below currently copies all the data from a cell in wbS, col E to
the other col C on the other sheet. I need to split the data to C and E on
the new sheet (col D will have the v in it).
.Range("C" & lngNewRow).Value = wbS.Range("E" & lngRowNo)

I hope that makes sense!
--
Traa Dy Liooar

Jock


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 440
Default splitting names from one cell to two cells

How simple is that? It falls down though when there's a 'v' in a name in a
cell but I can use that function for other projects.
Thanks.
--
Traa Dy Liooar

Jock


"helene and gabor" wrote:

Hello Jock,

A simple way to achieve name separation in Excel 2007 consists of the
following steps:
Leave column F free
mark your list of names to be separated
data
text to column
delimited
Convert text to Column Wizard delimiter: other, v (unmark others)
Column E will have all data up to "v", Column F the rest.

best regards

Gabor Sebo
------------------------------------------------------------------------------------------------------------------------------------------------------------------


"Jock" wrote in message
...
In cells in column E, I have names (could be John Doe, Dr John Stephen
Henry
Doe, could be a company name) which are seperated by the character "v"
which
indicates parties on one side versus parties on the other side.
I only need to split the data in cells in E which will be dictated by
ActiveCell.Row
How can I split the data in a cell in E into everything to the left of the
"v" to sheet2, lastrow + 1 (I've already got that bit working) col C, and
everything after the "v" to col E on that same sheet?

The line below currently copies all the data from a cell in wbS, col E to
the other col C on the other sheet. I need to split the data to C and E on
the new sheet (col D will have the v in it).
.Range("C" & lngNewRow).Value = wbS.Range("E" & lngRowNo)

I hope that makes sense!
--
Traa Dy Liooar

Jock


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
Splitting cell contents into 2 cells Florence Tay Excel Discussion (Misc queries) 1 May 17th 10 01:55 PM
Splitting one cell into multiple cells Money Penni Excel Discussion (Misc queries) 2 February 10th 09 08:16 PM
Add Newline(s) inside a Cell Without Splitting Content into Different Cells Emily[_3_] Excel Programming 1 September 5th 06 11:31 PM
Question for Bob Phillips re Splitting Names from Cells Paul Sheppard Excel Discussion (Misc queries) 8 August 3rd 05 09:00 AM
Splitting names from cells GoesLikeStink Excel Discussion (Misc queries) 2 July 30th 05 07:16 AM


All times are GMT +1. The time now is 09:46 AM.

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

About Us

"It's about Microsoft Excel"