Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Edit within a cell to select parts

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Edit within a cell to select parts

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Edit within a cell to select parts

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Edit within a cell to select parts

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Edit within a cell to select parts

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Edit within a cell to select parts

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
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
How do I select(fast) parts of long doc? suncat Excel Discussion (Misc queries) 4 February 5th 09 11:22 AM
Select & edit items in a listbox in VBA poppy Excel Programming 6 May 12th 06 01:10 PM
using list box to edit or select data BigPig Excel Discussion (Misc queries) 4 February 23rd 06 01:31 AM
using list box to edit or select data BigPig Excel Worksheet Functions 0 February 20th 06 04:13 PM
How do I select only specific parts of one field? wearfinkle Excel Worksheet Functions 1 February 21st 05 03:46 PM


All times are GMT +1. The time now is 06:01 PM.

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"