Results 1 to 4 of 4

Code to search for matching values in two columns, take text from that row and copy

Threaded View

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

    Code to search for matching values in two columns, take text from that row and copy

    Hello

    To my ability it's a bit complicated.
    However my problem is that I have several hundred sheets which have to do the same procedure.

    I have to search a row with ID's, whenever that number changes, I have to put in a cell above and below when the numbers changes.
    SO for example I have in row C:
    111
    111
    222
    222
    333

    that have to be:

    111
    111
    (new row)
    222
    222
    (new row)
    333

    Then I have to type in a certain text below and above when the value changes.
    I have this code to search and insert a cell:

    Sub InsertRows()
    Dim lastRow As Long
    Dim rowPtr As Long
    
    lastRow = Range("C" & Rows.Count).End(xlUp).Row
    For rowPtr = lastRow To 2 Step -1
    If Not IsEmpty(Range("C" & rowPtr)) Then
    If Range("C" & rowPtr) <> Range("C" & rowPtr - 1) Then
    Range("C" & rowPtr).EntireRow.Insert
    End If
    End If
    Next
    End Sub
    However I have to seach column B
    for matching values.
    so column b will have the same values somewhere I.e:
    111
    111
    222
    222
    333
    I have to find that matching value and copy the text from the corresonding row (in column B) to the inserted in the rows the macro made when the values in column C changes.
    Hope I have made my issue understandable, please tell me if it helps to make some sort of draft to upload or something.

    Appreciate any help or guidance.
    Thanks in advance

    Kind regards
    Last edited by arlu1201; 05-23-2014 at 12:11 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 3
    Last Post: 03-14-2014, 06:46 PM
  2. Compare columns and finding matching values/text
    By debake in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-02-2014, 09:27 AM
  3. Code to search for matching text in a table then copy next line
    By douglasm in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-27-2014, 12:10 PM
  4. Replies: 0
    Last Post: 10-07-2013, 10:24 AM
  5. [SOLVED] Search for a value in a column and copy row to new sheet for all matching values
    By mrcois in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-20-2012, 12:09 PM

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