I am trying to clean up my code by using named ranges so that it will still work if/when others add columns or rows to the spreadsheet. These should be pretty easy solutions for most of you but I can't seem to find any answers online.
Here are 2 examples of the code I am trying to update:
I was thinking that replacing "A" with "namedRange" would work but I suppose that's not how the Columns application works. How can I modify the code below to work with a named range instead of the fixed column "A"?
' Moves cursor to the first empty row.
Columns("A").Find("", Cells(Rows.Count, "A")).Select
For the following I would have thought that replacing "AU" with "namedRange" would do the trick as that's how things have worked for me in the past using the Range application. Unfortunately I get an error when I make the change. I'm sure it's something pretty simple but I can't figure it out.
' Creates separators between unique samplings
Dim LR As Long, i As Long, j As Long
LR = Range("AU" & Rows.Count).End(xlUp).Row
For i = LR + 1 To 2 Step -1
With Range("AU" & i)
If .Value <> .Offset(-1).Value Then
.Offset(-1).EntireRow.Borders(xlEdgeBottom).Weight = xlMedium
End If
End With
Next i
Bookmarks