I have an Excel spreadsheet which gets updated daily.
It generates a list, based on the updated data, of everyone that needs to complete a particular task that day. That list changes in length day-by-day.
To accomplish the necessary output, it uses formulas in an "if another cell in this row isn't blank, do..." structure:
=IF(LEN(I4)=0),"",<get a name from elsewhere>)
This list can be quite long. Rather than require the user to scroll excessively, I would like to provide a "copy to clipboard" button. Users then paste the rows into another application.
I can copy a list with fixed length, say M4 through M500, to the clipboard. But let's say that today, the list goes to M286, and tomorrow it's to M117, and so on. I would like to copy only populated cells.
Here's what I've pieced together from Google:
Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
Dim xSheet As Worksheet
firstBlankRow = Worksheets("Sheet1").Range("M4").End(xlDown).Row + 1
MsgBox (unusedRow)
Set xSheet = ActiveSheet
xSheet.Range("M4:M" & firstBlankRow).Copy
Application.ScreenUpdating = True
End Sub
This finds the last cell with a formula in it. That's not what I'm going for. I want the last cell with a value in it, that value being generated by the formula. In this particular case, "last cell with a value" will always be "cell before the first blank cell". There will be no gaps in the list.
How do I find up to the last cell with a value?