Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a spreadsheet of order numbers/names in one cell like this
20070001 Mickey Mouse 20070003 Daffy Duck 2006001222 Mini Mouse 200500345 Pluto In VB, is there a way to select out just the number, cut it out, and paste in different cell? Just have a few hundred to do and parsing the cell by space requires a recombine of all the names. Thanks. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Is it the case that the number portion will contain zero spaces and will
always end with a space? If so, use something like Sub AAA() Dim Pos As Integer Dim S As String S = Range("A1").Text Pos = InStr(1, S, Chr(32), vbBinaryCompare) If Pos Then Debug.Print Left(S, Pos - 1) Range("B1").Value = Left(S, Pos - 1) Else Debug.Print "no space found" End If End Sub -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting www.cpearson.com (email on the web site) "fatherof5clones" wrote in message ... I have a spreadsheet of order numbers/names in one cell like this 20070001 Mickey Mouse 20070003 Daffy Duck 2006001222 Mini Mouse 200500345 Pluto In VB, is there a way to select out just the number, cut it out, and paste in different cell? Just have a few hundred to do and parsing the cell by space requires a recombine of all the names. Thanks. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Jun 26, 7:29 am, fatherof5clones
wrote: I have a spreadsheet of order numbers/names in one cell like this20070001MickeyMouse 20070003 Daffy Duck 2006001222 MiniMouse 200500345 Pluto In VB, is there a way to select out just the number, cut it out, and paste in different cell? Just have a few hundred to do and parsing the cell by space requires a recombine of all the names. Thanks. It is easier to do if the number has a fixed number of digits. Then you can use the left/right function combined with the value function to grab the number. If you are uncertain how to do that, drop me a note and I'll reply with a more detailed explanation. If, however, the magnitude of the number is uncertain, but you know for sure that there is a space between the number and the text, then you can use the find function (looking for the space) in conjunction with left and value to get the job done. Let me know which case you are dealing with, and i'll drop in a more detailed response. Did you mention VB? For this simple thing, you won't need to use VB...just Excel formulas |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Use two formulas, one to get the number, and the other to get the name. For a value in cell A2, use
=LEFT(A2,FIND(" ",A2)-1) =MID(A2,FIND(" ",A2)+1,LEN(A2)) HTH, Bernie MS Excel MVP "fatherof5clones" wrote in message ... I have a spreadsheet of order numbers/names in one cell like this 20070001 Mickey Mouse 20070003 Daffy Duck 2006001222 Mini Mouse 200500345 Pluto In VB, is there a way to select out just the number, cut it out, and paste in different cell? Just have a few hundred to do and parsing the cell by space requires a recombine of all the names. Thanks. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Bernie...worked great...coupled with the automated For...Next statment and
runs great. Thanks. "Bernie Deitrick" wrote: Use two formulas, one to get the number, and the other to get the name. For a value in cell A2, use =LEFT(A2,FIND(" ",A2)-1) =MID(A2,FIND(" ",A2)+1,LEN(A2)) HTH, Bernie MS Excel MVP "fatherof5clones" wrote in message ... I have a spreadsheet of order numbers/names in one cell like this 20070001 Mickey Mouse 20070003 Daffy Duck 2006001222 Mini Mouse 200500345 Pluto In VB, is there a way to select out just the number, cut it out, and paste in different cell? Just have a few hundred to do and parsing the cell by space requires a recombine of all the names. Thanks. |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You're welcome, but you don't need a For...Next structu
Sub Macro1() Dim myRow As Long myRow = Cells(Rows.Count, 1).End(xlUp).Row Range("B2:B" & myRow).FormulaR1C1 = _ "=LEFT(RC[-1],FIND("" "",RC[-1])-1)" Range("C2:C" & myRow).FormulaR1C1 = _ "=MID(RC[-2],FIND("" "",RC[-2])+1,LEN(RC[-2]))" End Sub HTH, Bernie MS Excel MVP "fatherof5clones" wrote in message ... Bernie...worked great...coupled with the automated For...Next statment and runs great. Thanks. "Bernie Deitrick" wrote: Use two formulas, one to get the number, and the other to get the name. For a value in cell A2, use =LEFT(A2,FIND(" ",A2)-1) =MID(A2,FIND(" ",A2)+1,LEN(A2)) HTH, Bernie MS Excel MVP "fatherof5clones" wrote in message ... I have a spreadsheet of order numbers/names in one cell like this 20070001 Mickey Mouse 20070003 Daffy Duck 2006001222 Mini Mouse 200500345 Pluto In VB, is there a way to select out just the number, cut it out, and paste in different cell? Just have a few hundred to do and parsing the cell by space requires a recombine of all the names. Thanks. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I select(fast) parts of long doc? | Excel Discussion (Misc queries) | |||
Select & edit items in a listbox in VBA | Excel Programming | |||
using list box to edit or select data | Excel Discussion (Misc queries) | |||
using list box to edit or select data | Excel Worksheet Functions | |||
How do I select only specific parts of one field? | Excel Worksheet Functions |