+ Reply to Thread
Results 1 to 3 of 3

add values before semicolon

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: add values before semicolon

    Here's another...

    Private Sub CommandButton1_Click()
        Dim n, i As Long, ii As Long, x, y
        With CreateObject("vbscript.regexp")
            .MultiLine = True
            .Global = True
            .IgnoreCase = False
            .Pattern = "(\s\d+;)"
    
            x = Range("B2:E" & Range("B" & Rows.Count).End(xlUp).Row).Value
            ReDim y(2 To UBound(x), 1 To 4)
            For i = 2 To UBound(x)
                For ii = 2 To 4
                    Set myMatches = .Execute(x(i, ii))
                    For Each n In myMatches
                        y(i, ii) = Val(y(i, ii)) + Val(Trim(Split(n, ";")(0)))
                    Next n
                Next ii
            Next i
        End With
        Range("H3").Resize(UBound(y, 1) - 1, UBound(y, 2)).Value = y
        Range("H2").Resize(1, 4).Value = Application.Index(x, 1, 0)
        Range("H2").Resize(UBound(x)).Value = Application.Index(x, 0, 1)
    End Sub
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Transpose single row containing semicolon separated values to column
    By Wilco84 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 09-04-2013, 07:50 AM
  2. Replies: 4
    Last Post: 05-11-2013, 10:47 PM
  3. forumla to separate values with semicolon
    By kuder mcgavin in forum Excel General
    Replies: 5
    Last Post: 10-15-2012, 12:38 PM
  4. Formatting zip codes to semicolon deliminated values
    By mattjdohm in forum Excel General
    Replies: 2
    Last Post: 09-10-2008, 08:24 PM
  5. Column with semicolon-separated values
    By nsv in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-22-2006, 08:22 AM

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