Require assistance with code

O

OssieMac

It will be much appreciated if someone can tell me what I am doing wrong. The
following code works perfectly:-

Dim c
Dim inputRnge As Range

Set inputRnge = Sheets("Input Data").Range("A:A")
For Each c In inputRnge
If c.Value = 0 Then Exit For
'More code continues here for values > zero

However, I want to be able to address columns by their numeric equivalent
and when I put the code in as follows, it fails on the last line with an
error:
Runtime error 13 Type mismatch.

Set inputRnge = Sheets("Input Data").Columns(1)
inputRnge.Select 'This line for testing only and it works.
For Each c In inputRnge
If c.Value = 0 Then Exit For 'Fails on this line
'More code continues here

The only change to the code is on the Set inputRnge but testing this by
selecting it works which indicates it should be O.K. but the code fails on
the line:
If c.Value = 0 Then Exit For

Like I said, all help will be greatly appreciated.

Regards,

OssieMac
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top