+ Reply to Thread
Results 1 to 2 of 2

VB & Excell

Hybrid View

  1. #1
    Registered User
    Join Date
    07-25-2009
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2007
    Posts
    4

    VB & Excell

    Someone helped me write the below code but now i need to change it so that the fields append with a ¬ or ? as a delimiter rather than a comma (,)

    any ideas which character is telling it to delimite as a commas?



    Sub ptest()
    Dim a, b(), i As Long, n As Long
    With Range("a2", Range("a" & Rows.Count).End(xlUp)).Resize(, 2)
    a = .Value
    ReDim b(1 To UBound(a, 1), 1 To 2)
    With CreateObject("Scripting.Dictionary")
    .CompareMode = vbTextCompare
    For i = 1 To UBound(a, 1)
    If Not IsEmpty(a(i, 1)) Then
    If Not .exists(a(i, 1)) Then
    n = n + 1
    b(n, 1) = a(i, 1)
    .Add a(i, 1), n
    End If
    ' b(.Item(a(i, 1)), 2) = b(.Item(a(i, 1)), 2) & " " & a(i, 2)

    b(.Item(a(i, 1)), 2) = b(.Item(a(i, 1)), 2) & IIf(b(.Item(a(i, 1)), 2) <> "", ", ", "") & a(i, 2)

    End If
    Next
    End With
    ' .Value = b
    End With

    Sheets("Sheet1").Range("C1").Resize(n, 2).Value = b

    End Sub

  2. #2
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983

    Re: VB & Excell

    Please take a couple of minutes and read ALL theForum Rules then wrap your VBA code (Rule 3)
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1