Results 1 to 7 of 7

insert multiple cells in row if contents of one cell do not match contents of another

Threaded View

  1. #1
    Registered User
    Join Date
    12-06-2012
    Location
    Tucson, AZ
    MS-Off Ver
    Excel 2010
    Posts
    7

    insert multiple cells in row if contents of one cell do not match contents of another

    I have a worksheet that is 4 columns by 16331 rows. I want to shift the contents of cells A through C in row n down if the contents of cell C for that row n do not match the contents of cell D for that row n. The contents of column D should never shift. I constructed a for/then/next loop so that the macro will ask whether the contents of cell C row n match the contents of cell D row n for each n until n=16331.

    I have pasted an small example below to illustrate an example of what I have (before) and what I would like to accomplish (after).

    Here is the macro:

    SSub Move_totals_down()
    Application.ScreenUpdating = False
    Dim r As Long
    Dim n As Long
    r = Range("C16331").End(xlUp).Row
    n = Range("D16331").End(xlUp).Row
    For i = 2 To r
    For l = 2 To n
    If Range("C" & i).Text <> Range("D" & l).Text Then
    Cells(r, "A:C").Insert Shift:=xlDown
    End If
    Next l
    Next i
    Application.ScreenUpdating = True
    End Sub

    Nothing happens when I run it. I guess it's better than an error message, but not by much.

    Vanessa
    Attached Files Attached Files

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