ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   set range (https://www.excelbanter.com/excel-programming/383212-set-range.html)

Stefi

set range
 
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


Don Guillett

set range
 
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


--
Don Guillett
SalesAid Software

"Stefi" wrote in message
...
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




Dave Peterson

set range
 
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.



Stefi wrote:

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


--

Dave Peterson


All times are GMT +1. The time now is 08:51 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com