MistakesWereMade
Board Regular
- Joined
- May 22, 2019
- Messages
- 103
I've listed my code below. I want to be able to set the first empty cell's range in a column equal to the range of variable "PasteCell". However, with my code, I get the error "Method 'Range' of object '_Global' failed when trying to msgbox the row location of PasteCell.
Any ideas?
Any ideas?
Code:
Dim sourceCol As Integer, rowCount As Integer, currentRow As Integer
Dim currentRowValue As String
Dim PasteCell As Variant
With Sheets("Inventory")
sourceCol = 7 'column F has a value of 6
rowCount = Cells(Rows.Count, sourceCol).End(xlUp).Row
'for every row, find the first blank cell and select it
For currentRow = 3 To rowCount
currentRowValue = Cells(currentRow, sourceCol).Value
If IsEmpty(currentRowValue) Or currentRowValue = "" Then
PasteCell = Sheets("Inventory").Range(currentRow & sourceCol)
End If
Next
MsgBox (Range(PasteCell).Row)
End With