Results 1 to 2 of 2

CONCATENATE rows and copy to specific rows when values change in between different values

Threaded View

  1. #1
    Registered User
    Join Date
    03-06-2014
    Location
    Denmark
    MS-Off Ver
    Excel 2010
    Posts
    83

    CONCATENATE rows and copy to specific rows when values change in between different values

    Hello

    I have a lot of workbooks, which have to be decomposed in the same way.

    I have the ollowing code to insert new rows when the value in column B changes and insert text into those rows:

    Sub InsertRowsV2()
    Dim lastRow As Long
    Dim rowPtr As Long
    Dim strT1 As String
    Dim strT2 As String
    
    strT1 = "Begin-Total"
    strT2 = "End-Total"
    
    lastRow = Range("B" & Rows.Count).End(xlUp).Row
    Range("B" & lastRow + 1).Value = strT2
    For rowPtr = lastRow To 3 Step -1
    If Range("B" & rowPtr) <> Range("B" & rowPtr - 1) Then
    Range("B" & rowPtr).Resize(2).EntireRow.Insert
    Range("B" & rowPtr).Value = strT2
    Range("B" & rowPtr + 1).Value = strT1
    End If
    Next rowPtr
    
    Range("B2").Resize(2, 1).EntireRow.Insert
    Range("B2").Resize(2, 1).EntireRow.Interior.ColorIndex = xlNone
    Range("B3").Value = strT1
    
    End Sub
    However, I now have to CONCATENATE the values between the inserted rows, because in column A I have different numbers, and I have to take the lowest number and the highest number in between those rows and copy paste it to the cell next to the strings (Begin-total and end-total), so that would be in column C in this example.
    I have attached a little example...
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Pick, copy and paste rows containing specific range of values
    By Kenneyd71 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-20-2012, 09:44 AM
  2. [SOLVED] Copy Specific Rows of Data Based On two Values
    By timbo1957 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-14-2012, 12:03 AM
  3. Loop to copy all rows containing specific values
    By WDWILSON in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-13-2012, 11:11 PM
  4. How can I copy rows based on specific data values?
    By OyGevalt in forum Excel General
    Replies: 9
    Last Post: 03-31-2012, 12:09 PM
  5. Formula to copy to values to specific rows
    By Simon1185 in forum Excel General
    Replies: 4
    Last Post: 12-03-2009, 04:55 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