I am new to VBA editing, and I have written a code that is giving "Run-time error '91': Object variable or With block variable not set". The code is designed to copy any rows with a value in Column F, and paste them in another worksheet.
I am wondering if, in the event there are no values at all in Column F, the code produces an error. The code is below. I have marked the line that "Debug" leads me to in bold below.
'This macro copy-pastes rows from the Data Collection tab into the Data Storage tab, then deletes duplicates
'Find rows that contain any value in column F and copy them
Dim cell As Range
Dim selectRange As Range
On Error GoTo Errorcatch
For Each cell In ActiveSheet.Range("F:F")
If (cell.Value <> "") Then
If selectRange Is Nothing Then
Set selectRange = cell
Set selectRange = Union(cell, selectRange)
'Paste copied selection to the worksheet 'Data Storage' on the next blank row
Sheets("Data Storage").Range("A65536").End(xlUp).Offset(1, 0).PasteSpecial _
Maybe "selectRange" has no values and Excel doesn't know which row to select?