Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 413
Default Split & Trim question

Sample data:

| col B | col C | col D | col E | col F |
10 0. 88 0.3 4 m2 1 0.22
needs to become
10 0.88 0.34 m2 10.22

I use a test on col F to find suitable rows.
In the case of the col B cell, I need to keep the '10', but move
the rest of cell's contents into the start of the adjacent cell (same
row) so:

Dim C As Range, x As Variant
With ActiveSheet
For Each C In Intersect(Range("F:F"), ActiveSheet.UsedRange)
If Not IsEmpty(C) Then
If Not C.Value = "Unit" Then
x = Split(C.Offset(0, -4), " ")
If UBound(x) 0 Then 'there is data to be moved
C.Offset(0, -3).Value = x(1) & "." &
C.Offset(0, -3).Value
C.Offset(0, -4).Value = x(0)

So col C should now be: 0. 88 0.3

I've deliberately added to col C by inserting a space. If col C originally
began with a number (88) then I don't need the space....but if it's a text
value then I need the space....How do I test this please?

In the above example, the original col B contents could contain several
elements, separated by one or many spaces.

How do I move all the Split values apart from x(0) into col C, and
then with col C, remove all spaces (except one) between the "strings"?

Obviously this will replicate across cols D-F.

Any help much appreciated.

Regards




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.601 / Virus Database: 382 - Release Date: 29/02/2004


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Split & Trim question

Possibly:

sStr = "0. 88"

iloc = Instr(sStr," ")
if iloc 0 the
sStr1 = Left(sStr,iloc-1)
else
sStr1 = sStr
End if
if isnumeric(sStr1)

--
Regards,
Tom Ogilvy



"Stuart" wrote in message
...
Sample data:

| col B | col C | col D | col E | col F |
10 0. 88 0.3 4 m2 1 0.22
needs to become
10 0.88 0.34 m2 10.22

I use a test on col F to find suitable rows.
In the case of the col B cell, I need to keep the '10', but move
the rest of cell's contents into the start of the adjacent cell (same
row) so:

Dim C As Range, x As Variant
With ActiveSheet
For Each C In Intersect(Range("F:F"), ActiveSheet.UsedRange)
If Not IsEmpty(C) Then
If Not C.Value = "Unit" Then
x = Split(C.Offset(0, -4), " ")
If UBound(x) 0 Then 'there is data to be moved
C.Offset(0, -3).Value = x(1) & "." &
C.Offset(0, -3).Value
C.Offset(0, -4).Value = x(0)

So col C should now be: 0. 88 0.3

I've deliberately added to col C by inserting a space. If col C originally
began with a number (88) then I don't need the space....but if it's a text
value then I need the space....How do I test this please?

In the above example, the original col B contents could contain several
elements, separated by one or many spaces.

How do I move all the Split values apart from x(0) into col C, and
then with col C, remove all spaces (except one) between the "strings"?

Obviously this will replicate across cols D-F.

Any help much appreciated.

Regards




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.601 / Virus Database: 382 - Release Date: 29/02/2004




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
Trim text and split across three columns Juswant Rai Excel Discussion (Misc queries) 4 September 4th 09 09:03 AM
Trim question Ayo Excel Discussion (Misc queries) 7 July 18th 08 10:28 PM
Split UPC Question MikeD1224 Excel Discussion (Misc queries) 2 February 16th 07 07:29 PM
Another, sort of trim question stapleton2308 Excel Discussion (Misc queries) 2 February 15th 06 06:54 PM
Right & Split question Stuart[_5_] Excel Programming 8 February 29th 04 07:53 AM


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