Forum Discussion

Fennster's avatar
Fennster
Copper Contributor
May 16, 2021
Solved

Macro functions

Hi I’m new to macros and I want to be able to move a range of cells to another range of cells if a preceding cell in that range equals (say) YES. So, How do I test if a cell (A1 say in Sheet 1) equal...
  • HansVogelaar's avatar
    HansVogelaar
    May 17, 2021

    Fennster 

    You have to loop through the cells:

     

    Sub MoveCells()
        Dim r As Long
        Application.ScreenUpdating = False
        For r = 2 To 100
            If Worksheets("PICK").Range("A" & r).Value = "YES" Then
                Worksheets("PICK").Range("C" & r).Resize(1, 3).Cut _
                    Destination:=Worksheets("PRINT").Range("A" & r)
            End If
        Next r
        Application.CutCopyMode = False
        Application.ScreenUpdating = True
    End Sub

Resources