set range

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All,

Why

Dim fogadrng As Range
Range("C8:C12,E8:E12,G8:G12,I8:I12,K8:K12").Select
Set fogadrng = Selection

works and

Dim fogadrng As Range
Set fogadrng = Range("C8:C12,E8:E12,G8:G12,I8:I12,K8:K12")

does not?

Thanks,
Stefi
 
I just tested this in xl2002 and it worked.??

Sub setrng()
Dim fogadrng As Range
Set fogadrng = Range("C8:C12,E8:E12,G8:G12,I8:I12,K8:K12")
For Each c In fogadrng
MsgBox c.Address
Next
End Sub

or
for each c in range("C8:C12,E8:E12,G8:G12,I8:I12,K8:K12")
MsgBox c.Address
Next
 
How are you running this and what version of excel are you using?

I don't have xl97 anymore, but if you're running this from a commandbutton from
the control toolbox toolbar (in xl97), then change that commandbutton's
..takefocusonclick property to false.
 

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

Back
Top