Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Well, that is strange, because it does not work on my system. I omitted the
rest because Err.Number IS not equal to 0, but 1004. After the Err.Number<0 statement I display a message and abort the routine. If I do add the message box you propose, it is not displayed and rng remains equal to NOTHING. I am using Excel 2002 and 2003, maybe that makes a difference (I doubt it)? "Bernie Deitrick" wrote: 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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm using XL XP (2002).
Perhaps it is due to a separator setting? (Since VBA is US-centric, it could be that you have a semicolon (or other separator) instead of a comma between the two ranges, and Range expects a comma....) Add the line Range("A1").Value = s just after s = refCtrl.Value (to make it easy to copy and paste into a message) What is the value of s when the code fails? If it does have a semicolon - for example: 'Sheet 1'!$B$4:$B$8;'Sheet 1'!$B$19:$B$23 Then perhaps adding s = Replace(s,";",",") will help.... HTH, Bernie MS Excel MVP "Arne" wrote in message ... Well, that is strange, because it does not work on my system. I omitted the rest because Err.Number IS not equal to 0, but 1004. After the Err.Number<0 statement I display a message and abort the routine. If I do add the message box you propose, it is not displayed and rng remains equal to NOTHING. I am using Excel 2002 and 2003, maybe that makes a difference (I doubt it)? "Bernie Deitrick" wrote: 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 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
As soon as I read it, I knew that had to be it!
I inserted s = Replace(s, Application.International(xlListSeparator), ",") and evrything works fine! Thanks! "Bernie Deitrick" wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
RefEdit control | Excel Programming | |||
passing range from RefEdit control | Excel Programming | |||
Setting Caption for the RefEdit box? | Excel Programming | |||
Shift-Control Arrow and RefEdit Control? | Excel Programming | |||
RefEdit control bug | Excel Programming |