WriteLine error

teachman

Active Member
Joined
Aug 31, 2011
Messages
321
Morning all,

The code snippet below is the subject of my question.

Code:
        If r = 7 Then
            analyte = "Horizon Depth to Top"
             If Cells(r, K) = 6 Then
                Err = Err + 1
[COLOR=#ff0000]                stream.WriteLine analyte & " is missing in cell " & KOL & r & ", please correct."
[/COLOR]             End If
             If Cells(r, K) < 0 Or Cells(r, K) > 9999 Then
              Err = Err + 1
              stream.WriteLine analyte & " is outside range, 0 to 9999, inclusive in cell " & KOL & r & ".  Please correct."
             End If
        End If

The line in red gives me a run-time error '424'. Object required.

The file has the necessary 'Microsoft Scripting Runtime' reference checked off.
An earlier (in the code) error catching If..End If, shown below, executed correctly and wrote the stream.WriteLine statement to the error log file.

Code:
    If Range("P2") = "" Then
        Err = Err + 1
        stream.WriteLine Err & " Missing Date.  Please enter date, cell P2."
    End If

I have been using this same basic construct for many projects without a problem.

Any help would be much appreciated.

Thanks,

George Teachman
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

Forum statistics

Threads
1,214,653
Messages
6,120,750
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top