Results 1 to 3 of 3
  1. #1
    madsc1 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Posts
    6

    Extract data at end of cell

    Columns:
    First_Name Last_Name Address City Postal

    Working with just the address data, example: address cell value 123 Any Street 201, 201 being the apartment number, 123 the street address.. This is the VBA code to extract apartment number and move data 1 column to the right into an empty column. My problem is it is picking the front of the address eg 123, not the apartment # eg 201. New to VBA so I'm not sure how to get it to extract from the right. Anywhere I insert the right qualifier, I get compile errors. Any ideas!

    Sub SplitAddresses()
    Dim s As String
    Dim i As Integer
    Dim cell As Range
    For Each cell In Range("E:E").Cells


    s = cell.Value
    If s = "" Then Exit Sub
    i = InStr(s, " ")
    If i > 0 Then
    cell.Offset(0, 1).Value = Mid(s, i + 1)
    cell.Value = Left(s, i - 1)
    End If
    Next
    End Sub

    Thanks.


  2. #2
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    To search from the right, use InStrRev() .

  3. #3
    madsc1 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Posts
    6
    Much Thanks,
    Peter

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Extract Partial Data
    By madsc1 in forum Access
    Replies: 6
    Last Post: 03-16-2011, 03:43 PM
  2. Extract Text Data
    By tmcrouse in forum Queries
    Replies: 5
    Last Post: 05-25-2010, 11:34 AM
  3. Replies: 3
    Last Post: 05-13-2010, 08:18 PM
  4. Condensing Rows of Data into one Cell
    By alexandermorris in forum Access
    Replies: 1
    Last Post: 02-25-2010, 07:47 AM
  5. Can we post Access cell data to Excel cell properties?
    By Zethro in forum Import/Export Data
    Replies: 1
    Last Post: 12-13-2005, 08:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums