Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Any ideas... Doesn't work...

I can't see what I have wrong on this macro... If I have the following
sample data:

Column C: 1234 Towne Lake Pkwy., Bldg. 222
Column D: Area 12, Suite 123, Woodstock
Column E: GA

I need anything to the left of the last comma in column D to be appended
to the end of the info. in column C. This doesn't seem to be working
right. Any ideas???

Thanks,

Andrew

Here's the macro!

Sub Address()

Dim i As Long, lastrow As Long
Dim j As Long, k As Long, iloc As Long
Dim sStr As String
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
For i = 1 To lastrow Step 1
sStr = Cells(i, 4).Value
j = Len(sStr)
iloc = 0
For k = j To 1 Step -1
If Mid(sStr, k, 1) = "," Then
iloc = k
Exit For
End If
Next
If iloc < 0 Then
Cells(i, 3).Value = Cells(i, 4). _
Value & " " & _
Trim(Left(sStr, iloc - 1))
Cells(i, 4).Value = Trim( _
Right(sStr, j - iloc))
End If
Next
End Sub

*** 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
Anyone else have any ideas?? M&M[_2_] Excel Discussion (Misc queries) 3 August 11th 07 01:51 PM
Any Ideas Greg B Excel Discussion (Misc queries) 7 May 16th 05 03:41 AM
Vlookup won't work, any other ideas? Huw Excel Worksheet Functions 0 February 17th 05 04:31 PM
Assign Macro to button in Excel doesnt work Any ideas? Mike@Becketts Excel Discussion (Misc queries) 2 December 20th 04 02:47 PM
formula from Excel97 doesn't work in Excel2003,any ideas why? nic Excel Worksheet Functions 6 November 8th 04 04:40 PM


All times are GMT +1. The time now is 03:31 AM.

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"