Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Left Function in code

Hello,

I have got a number that i need to split using code. Could somebody
please help me out.

it is always in this format 1234567-00

and i need to split it by the first 7 "1234567" in one column and then
the last two "00" in another column.
The minus "-" can be lost.

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Left Function in code

Les,

Try something like the following:

Dim S As String
Dim N1 As String
Dim N2 As String
S = "1234567-00"
N1 = Left(S, 7)
N2 = Right(S, 2)
Range("A1").Value = "'" & N1
Range("B1").Value = "'" & N2


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Les Stout" wrote in message
...
Hello,

I have got a number that i need to split using code. Could

somebody
please help me out.

it is always in this format 1234567-00

and i need to split it by the first 7 "1234567" in one column

and then
the last two "00" in another column.
The minus "-" can be lost.

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Left Function in code

Thanks very much Chip, a further question to that.
The column has approx. 4000 parts in it would it be better to loop it
down? or do you have a better suggestion. I am wanting to do it
automated, running in the background.

Your assistance is much appreciated.

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Left Function in code

You can accomplish the same thing without VBA code, using two
formulas.

=LEFT(A1,7)
and
=RIGHT(A1,2)

Copy these formulas to cells B1 and C1, and then fill down as far
as you need to go.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Les Stout" wrote in message
...
Thanks very much Chip, a further question to that.
The column has approx. 4000 parts in it would it be better to

loop it
down? or do you have a better suggestion. I am wanting to do it
automated, running in the background.

Your assistance is much appreciated.

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



  #5   Report Post  
Posted to microsoft.public.excel.programming
Dnk Dnk is offline
external usenet poster
 
Posts: 8
Default Left Function in code

Try something Like this:

Sub ParseString()
Dim S As Variant
Dim r As Range
Dim c As Integer
Dim N1 As String
Dim N2 As String

c = 1
For Each S In Range("A1:A4000")
N1 = Left(S, 7)
N2 = Right(S, 2)
Cells(c, 2) = "'" & N1
Cells(c, 3) = "'" & N2

c = c + 1
Next S
End Sub
Derick



Les Stout wrote in message ...
Thanks very much Chip, a further question to that.
The column has approx. 4000 parts in it would it be better to loop it
down? or do you have a better suggestion. I am wanting to do it
automated, running in the background.

Your assistance is much appreciated.

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


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 to nest a left function within a sumif function? LisaK Excel Worksheet Functions 2 April 23rd 23 11:46 AM
LEFT function-all to left of a comma? Jennifer F Excel Worksheet Functions 1 January 21st 09 11:19 PM
How can I get a leading zero (ZIP code) to show in a LEFT() calc? MarketStEl Excel Worksheet Functions 2 December 11th 07 04:35 AM
Left vs Left$ function Andy Excel Discussion (Misc queries) 5 May 6th 07 04:06 AM
how to display zero at the left hand of a code in a cell say 045 Marie Excel Discussion (Misc queries) 3 June 12th 06 10:41 AM


All times are GMT +1. The time now is 03:00 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"