LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.misc
Charles
 
Posts: n/a
Default Using macro to copy a part of a cell content to next cell

Thanks Kevin.
But, as I wrote in reply to mrice, my data was not written using comma as a
delimiter. It was written as you'd write in an envelope: street address,
(sometimes no comma) city, state zipcode. There are no comma between
state-zip. If city names were only one word, I would be able to use
text-to-columns function. Do I have to put comma where necessary and use your
code? Well, I'd wait and explore my option before I decide to do that.
Thanks anyway.

Charles


"Kevin B" wrote:

The following macro splits data using a comma as a delimiter. The macro
assumes that the data resides in Column A and starts in row 1.

Sub ParseAddress()

Dim strVal As String
Dim lngRow As Long
Dim intCol As Integer
Dim varArray As Variant
Dim varItems As Variant

Range("C1").Select
strVal = ActiveCell.Offset(lngRow, -2).Value

Do Until strVal = ""
varArray = Split(strVal)
varItems = varArray
For Each varItems In varArray
ActiveCell.Offset(lngRow, intCol).Value = varItems
intCol = intCol + 1
Next varItems
lngRow = lngRow + 1
intCol = 0
strVal = ActiveCell.Offset(lngRow, -2)
Loop

End Sub

Perhaps this will get you pointed in the proper direction.
--
Kevin Backmann


"Charles" wrote:

I have lists of street address, city, state and zip code written in a cell.
I'd like to put those in different cells, like city in a street address in a
cell, city in a cell, so on...
There are about 500 hundred of them, and I don't want to do that one by one.
I thought of using macro and tried without success.
It seems to be working, but it failed to copy and paste new data. I mean,
instead of copying and pasting the zip code from the cell selected, it keeps
pasting the first one.
Please help me.

Charles



 
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
macro to find cell content in sheets and make sheet active Nigel Excel Discussion (Misc queries) 4 June 26th 14 02:38 PM
Can I search a cell for a value and extract part of content? Leben Excel Discussion (Misc queries) 1 December 16th 05 09:43 AM
Macro help - copy a cell down gjcase Excel Discussion (Misc queries) 3 September 4th 05 05:09 AM
vlookup to extract part cell content excelFan Excel Discussion (Misc queries) 2 December 5th 04 08:45 AM
GET.CELL Biff Excel Worksheet Functions 2 November 24th 04 07:16 PM


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