for each error
thanks for the reply. I thought I had used option explicit in the other code
as well so it didn't make sense to me that one would give me the error and
the other wouldn't. But as it turns out, I was wrong. I had neglected to
include option explicit. THanks again.
"KL" wrote:
The same code works to populate another list box. Why am I getting this
error?
The difference is the "Option Explicit" statement which requires all
variables to be declared.
Try:
Option Explicit
Private Sub UserForm_Activate()
Dim cell As Range
For Each cell In Range("cpName")
If cell.Value < "" Then
lstMnemonic.AddItem cell.Value
End If
Next cell
End Sub
Regards,
KL
|