Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

Any Excel Gurus out there?

Thread Tools
 
Search this Thread
 
Old Apr 22, 2004 | 10:43 PM
  #1  
Buckrogers's Avatar
Buckrogers
Thread Starter
Scooby Regular
 
Joined: Aug 2003
Posts: 2,644
Likes: 0
Default Any Excel Gurus out there?

I have some data in a single column. (Couple of thousand rows....)

I would like to be able to remove any "spaces" either before or after the actual content. Is this possible using VB or something?

I would also like to remove "*" from after say xyz123* and put it into the cell on the right of the original? (it is an actual * as opposed to wild character)
Again VB or something?

Thanks for any help in advance.

Buck
Reply
Old Apr 23, 2004 | 01:03 AM
  #2  
Eagle7's Avatar
Eagle7
Scooby Regular
 
Joined: Jan 2002
Posts: 960
Likes: 0
From: Plymouth
Default

assuming data is in column 1 and you want the stars moving to 2 put this in a macro:

Sub StarsNSpaces()
Dim x As Integer, s As String
For x = 1 To ActiveSheet.UsedRange.Rows.Count
s = Trim(CStr(Cells(x, 1)))
If Right(s, 1) = "*" Then
Cells(x, 1) = Mid(s, 1, Len(s) - 1)
Cells(x, 2) = "*"
End If
Next x
End Sub

if you need to change it, change the start value of x (for x=1) to be the row to start processing and change the reference to cells to be the correct column : A=1, B=2, C=3 etc.
Reply
Old Apr 23, 2004 | 06:59 AM
  #3  
Sheepsplitter's Avatar
Sheepsplitter
Scooby Regular
 
Joined: Nov 2001
Posts: 1,072
Likes: 0
Default

Can't you just export it as text and read it back in using * as delimiter?
Seems like this would be a much more efficient way of achieving your requirements.
Reply
Old May 10, 2004 | 12:03 AM
  #4  
Buckrogers's Avatar
Buckrogers
Thread Starter
Scooby Regular
 
Joined: Aug 2003
Posts: 2,644
Likes: 0
Default

Thanks Eagle7 that was just the job.

Sheepslipper, I think you are right, but in my specific case, could have been a bit tricky with the other data that is present. Eagle7's macro does the job (thanks to copy and paste) and Eagle7's macro wisdom!

Cheers anyway.

Buck
Reply
Old May 11, 2004 | 01:24 PM
  #5  
Mick's Avatar
Mick
Scooby Senior
iTrader: (1)
 
Joined: Nov 1998
Posts: 2,656
Likes: 4
Thumbs up

If you do a lot of complex Excel stuff, try this free set of tools from ASAP

http://www.asap-utilities.com/ - I found some brillliant stuff in there...

Cheers

Mick
Reply
Old May 11, 2004 | 01:45 PM
  #6  
Dracoro's Avatar
Dracoro
Scooby Regular
 
Joined: Sep 2001
Posts: 10,261
Likes: 0
From: A powerslide near you
Default

you can do both without using vba.

To remove outer (left and right) spaces use excel trim function e.g. '=trim(a1)'

To split the column, select the cells to split (or the whole column) then menu Data>Text To Columns and put in * as the delimiter

easy peasy pudding and pie
Reply
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
Mattybr5@MB Developments
Full Cars Breaking For Spares
28
Dec 28, 2015 11:07 PM
Mattybr5@MB Developments
Full Cars Breaking For Spares
12
Nov 18, 2015 07:03 AM
leg200
Subaru Parts
5
Oct 7, 2015 07:31 AM
has-scooby
Subaru Parts
4
Oct 6, 2015 03:47 PM
bluebullet29
General Technical
9
Oct 5, 2015 02:17 PM




All times are GMT +1. The time now is 02:52 AM.