+ Reply to Thread
Results 1 to 2 of 2

Only move row if column H = Y

Hybrid View

  1. #1
    Registered User
    Join Date
    06-15-2013
    Location
    usa
    MS-Off Ver
    Excel 2010
    Posts
    21

    Only move row if column H = Y

    I have this code that moves information from column A in sheet1 to column B on every 3rd row in sheet2. How can I modify this code to do exactly the same thing but only if column H in the row is "Y"?


    Sub move()
        Dim i As Long, n As Long
        n = 2
        With Sheets("sheet1")
            For i = 1 To .Range("a" & Rows.Count).End(xlUp).Row
                If .Cells(i, 1).Value <> "" Then
                    n = n + 3
                    Sheets("sheet2").Cells(n, "b").Value = .Cells(i, 1).Value
                End If
            Next
        End With
    End Sub

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,037

    Re: Only move row if column H = Y

    Try ths:
    Sub move()
        Dim i As Long, n As Long
        n = 2
        With Sheets("sheet1")
            For i = 1 To .Range("a" & Rows.Count).End(xlUp).Row
                If .Cells(i, 1).Value <> "" And .Cells(i,8)="Y" Then
                    n = n + 3
                    Sheets("sheet2").Cells(n, "b").Value = .Cells(i, 1).Value
                End If
            Next
        End With
    End Sub
    Never use Merged Cells in Excel

+ 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