View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default Subject: Setting a range from a refedit control

Arne,

The problem is with the code that you didn't post.

This works fine:

Dim s As String
Dim rng As Range
s = refCtrl.Value
On Error Resume Next
Set rng = Range(s)
MsgBox "The select range is " & rng.Address & Chr(10) & _
"It has " & rng.Areas.Count & " area(s), and a total of " & _
rng.Cells.Count & " cell(s)."

What are you doing AFTER this?


HTH,
Bernie
MS Excel MVP


"Arne" wrote in message
...
Hello,

On a form I have a refedit control wich is then used to set a range variable
for further processing:

Dim s As String
Dim rng as Range
s = refCtrl.Value
On Error Resume Next
Set rng = Range(s)
If Err.Number < 0 Then
...

This works fine as long as the range selected using the refedit control
consists of one area. However, it fails on multiple-area ranges. Is there a
simple way of setting the range in this case without having to write an
extensive procedure in which the string s is analyzed and the areas are added
to the range object?

TIA, Arne