-1

I made this code to delete and move the fields to the correct places. How can i make it that if i add more info the lines that were done should be skipped?

Range(Range("B2"),Range("B2").End(xldown)).Select
    Selection.Cut
Columns("H:H").Select
    ActiveSheet.Paste
Range(Range("C2"),Range("C2").End(xldown)).Select
    Selection.Cut
Range(Range("B2"),Range("B2").End(xldown)).Select
    ActiveSheet.Paste
Columns("C:F").Select
Range(Range("C2:F2"),Range("C2:F2").End(xldown)).Select
    Selection.Delete Shift:=xlToLeft

Columns("B:B").Select
    Selection.NumberFormat = "0"


End Sub
Community
  • 1
  • 1

1 Answers1

0

This structure will not only enable you to add conditions but will make your code faster and reduce the flashing effects while still showing parts of the progress.

For i = Range("B2").Row To Range("B2").End(xldown).Row 'from the first row to the last
    If YourCondition Then 'your condition can be equality, inequality, text check with wildcards, functions, whatever
        Cells(i,8).Value2 = Cells(i,2).Value2 'H equals B
        Cells(i,2).Value2 = "" 'B is nothing
        'and so on
    End If
Next i
user3819867
  • 1,114
  • 1
  • 8
  • 18