MagnaForce
New Member
- Joined
- Jul 1, 2021
- Messages
- 21
- Office Version
- 365
- Platform
- Windows
I want to be able to open any sheet and click on a cell to build a range from the active cell that I clicked on to the last row in the column.
The loop through cells to find the duplicates is working fine its just selecting a range first.
The loop through cells to find the duplicates is working fine its just selecting a range first.
VBA Code:
Sub SelectAndDetectDups()
Dim xRng1 As Range
Dim xCell1 As Range
'With the following line I have to select my range from the first cell and hold the mouse button and drag all the way to the last row, which could be in the thousands.
Set xRng1 = Selection 'I want to change this line so that I only have to select the first cell in the range that I want selected and the selection will be to the last row of the column that I am in.
For Each xCell1 In xRng1
If WorksheetFunction.CountIf(xRng1, xCell1.Value) > 1 Then
xCell1.Interior.ColorIndex = 3
End If
Next
End Sub