J
Jan Nademlejnsky
I am struggling with these problems in my macros:
How to code:
1. Move one row down in the same column?
2. Move one row down and one column right (left)?
3. Fill down to the last non empty cell in the left (right) column.
Basically I want to write a macro which will find duplicates and mark them
in the next column. How to modify statements below so they are universal
(relative) rather than specific. Example, I have numbers in A2: A150 and I
want to find duplicates, which is easy to do with code below. Now I want to
change it so it writes the formula into the column where the cell is
selected and fill it down just to row 150.
If I want to find duplicates in column G then I would click H1 and the macro
would do the rest.
Sub Duplicates()
ActiveCell.FormulaR1C1 = "Duplicates"
Range("B2").Select '<============ This should be one cell down
ActiveCell.FormulaR1C1 = "=IF(RC[-1]=R[-1]C[-1],1,"""")"
Range("B2:B5000").Select '<== This should from the last active down to
the last non empty cell in left column
Selection.FillDown
Range("B2").Select
Selection.AutoFilter
Selection.AutoFilter Field:=2, Criteria1:="1"
Rows("2:5001").Select
Selection.Delete Shift:=xlUp
Selection.AutoFilter
Range("B2").Select
End Sub
Appreciate your help
Thanks
Jan
How to code:
1. Move one row down in the same column?
2. Move one row down and one column right (left)?
3. Fill down to the last non empty cell in the left (right) column.
Basically I want to write a macro which will find duplicates and mark them
in the next column. How to modify statements below so they are universal
(relative) rather than specific. Example, I have numbers in A2: A150 and I
want to find duplicates, which is easy to do with code below. Now I want to
change it so it writes the formula into the column where the cell is
selected and fill it down just to row 150.
If I want to find duplicates in column G then I would click H1 and the macro
would do the rest.
Sub Duplicates()
ActiveCell.FormulaR1C1 = "Duplicates"
Range("B2").Select '<============ This should be one cell down
ActiveCell.FormulaR1C1 = "=IF(RC[-1]=R[-1]C[-1],1,"""")"
Range("B2:B5000").Select '<== This should from the last active down to
the last non empty cell in left column
Selection.FillDown
Range("B2").Select
Selection.AutoFilter
Selection.AutoFilter Field:=2, Criteria1:="1"
Rows("2:5001").Select
Selection.Delete Shift:=xlUp
Selection.AutoFilter
Range("B2").Select
End Sub
Appreciate your help
Thanks
Jan