Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Refedit question.

Hello .


I'm tryng to have my Refedit control to do this.

the user will click on the control then will select
a1
on Exit the refedit text should change to Sheet1!$A$1:Sheet!$H:$15
(I tried to do it without luck.)

Also I need to make sure they only select one cell in column A.

Thanks in advance.

Cesar Zapata


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Refedit question.

I put a commandbutton (Ok like) on the form and then validated from the

Option Explicit
Private Sub CommandButton1_Click()

Dim testRng As Range

Set testRng = Nothing
On Error Resume Next
Set testRng = Range(Me.RefEdit1.Value)
On Error GoTo 0

If testRng Is Nothing Then
Me.RefEdit1.SetFocus
MsgBox "Please select a range"
Exit Sub
End If

If testRng.Parent.Name < ActiveSheet.Name Then
Me.RefEdit1.SetFocus
MsgBox "On this sheet!"
Exit Sub
End If

If testRng.Cells.Count 1 Then
Me.RefEdit1.SetFocus
MsgBox "One cell only!"
Exit Sub
End If

If testRng.Column < 1 Then
Me.RefEdit1.SetFocus
MsgBox "must be in column A"
Exit Sub
End If

MsgBox testRng.Address

End Sub

===
You may want to be a little more lenient. Just pick up the row number from
first cell in their selected range:

Option Explicit
Private Sub CommandButton1_Click()

Dim testRng As Range

Set testRng = Nothing
On Error Resume Next
Set testRng = Range(Me.RefEdit1.Value)
On Error GoTo 0

If testRng Is Nothing Then
Me.RefEdit1.SetFocus
MsgBox "Please select a range"
Exit Sub
End If

If testRng.Parent.Name < ActiveSheet.Name Then
Me.RefEdit1.SetFocus
MsgBox "On this sheet!"
Exit Sub
End If

Set testRng = ActiveSheet.Cells(testRng.Row, 1)

MsgBox testRng.Address

End Sub


Cesar Zapata wrote:

Hello .

I'm tryng to have my Refedit control to do this.

the user will click on the control then will select
a1
on Exit the refedit text should change to Sheet1!$A$1:Sheet!$H:$15
(I tried to do it without luck.)

Also I need to make sure they only select one cell in column A.

Thanks in advance.

Cesar Zapata


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
RefEdit question tt Excel Discussion (Misc queries) 2 February 8th 06 03:42 AM
Crash upon using RefEdit Oliver Kharraz Excel Programming 3 November 18th 03 04:36 PM
refedit query Terry Excel Programming 7 October 27th 03 04:40 PM
RefEdit control bug Dag Johansen[_6_] Excel Programming 1 October 20th 03 12:32 PM


All times are GMT +1. The time now is 06:57 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"