Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 4th, 2003, 10:49 AM
SethandCheese SethandCheese is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 1 SethandCheese User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to SethandCheese Send a message via AIM to SethandCheese Send a message via Yahoo to SethandCheese
[VBScript] Excel Macro: Split string in cells?

I have a list of names [First Last] in a column of Excel cells (A1 through A340 or so). The person who did the data entry was silly enough to put both first and last name in the same cell... it fell on me to write a script that would split them. Too bad I know no VBA, only VB.NET...

Example: Cell A1 has "John Smith". The macro needs to split it into A1 "John" and A2 "Smith", or A2 and A3, or whatever.

From VB experience, I know I should use a For loop to step through the string until I find a space, then chop and move... but can someone help me with appropriate commands for a VBScript macro?

Thanks,
Seth

Reply With Quote
  #2  
Old October 6th, 2003, 07:45 AM
Fisherman's Avatar
Fisherman Fisherman is offline
Inherits Programmer.Slacker
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: Between my Id and your Ego
Posts: 2,178 Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 9 h 56 m 45 sec
Reputation Power: 111
Send a message via ICQ to Fisherman Send a message via AIM to Fisherman
I'll take a blind shot at this one.....

dim I as integer
dim C as character
for I = 1 to YourUpperLimit
for each C in .Cells(I,A).Value
if C="" then
.Cells(I,A).Value = Mid(.Cells(I,A).value,0,(C-1))
.Cells(I,B).Value = Mid(.Cells(I,A).value,C,(Len(cstr(.cells(I,A).Value)))
End If
Next C
Next I


It's a shot - I haven't messed with VBA in a really long time.
__________________
Fisherman

"Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction." - A.Einstein

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > [VBScript] Excel Macro: Split string in cells?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT