I have logic set-up in my program where it does the following:
After clicking a macro button, it generates 1 or more names in column B. In this example, let's say 2 names are generated after clicking the button:

My logic is set to where the name in column A fills down based on the last non-empty cell in column B. So, it does this:

Here is my code that is working perfectly fine if there's more than one item in column B:
With AssetToolSheet
n = .Cells(Rows.Count, "A").End(xlUp).Row
lrowb = .Cells(Rows.Count, "B").End(xlUp).Row
.Range("A" & n & ":A" & lrowb).FillDown
End With
Now, here's my issue. Sometimes, column B might only have one generated asset name.
Since the code is set in place as shown above, it will still fill down even though there is no need to fill down column A (there's only one generated name in column B, so no need to fill down anything in column A). This is what it does:

I want to prevent my code from filling down column A if there is only one generated asset name in column B. If there is more than one generated asset name in column B, my logic works perfectly fine.
Thanks!
CodePudding user response:
If colA max row = colB max row do nothing, else fill down.
Sub Filldown()
Dim AssetToolSheet
Dim N As Integer
Dim lrowb As Integer
Set AssetToolSheet = Sheet1
With AssetToolSheet
N = .Cells(Rows.Count, "A").End(xlUp).Row
lrowb = .Cells(Rows.Count, "B").End(xlUp).Row
If N <> lrowb Then
.Range("A" & N & ":A" & lrowb).Filldown
End If
End With
End Sub

