0
votes

I am getting the dreaded run-time 1004 error in my VBA app. I'm using Excel 2010.

The code is as follows:

    ThisWorkbook.Sheets(outputSheet).Activate
    Dim loopFlag As Boolean
    loopFlag = True
    While loopFlag
        If IsEmpty(ThisWorkbook.Sheets(outputSheet).Cells(outputRow, 1)) Then
            loopFlag = False

The error occurs on line "if IsEmpty..."

The variable outputSheet is passed in as a parameter to the sub. outputRow is defined further up in the sub.

I'm completely stumped by this, any help appreciated.

1
are you sure outputRow is a valid row number?brettdj
@brettdj - It is good to post it as an answer.sancho.s ReinstateMonicaCellio

1 Answers

0
votes

I found the answer, I had not set outputRow properly and it was an invalid value.

Always use Option Explicit in VBA!