PDA

View Full Version : RefEdit control to clear contents



YasserKhalil
06-28-2010, 06:42 AM
Hi great forum
:friends:

I have a simple userform with two controls : commandbutton and refedit
I want to use the refedit control to select some nonadjacent cells and the command button to clear the contents of these cells

Kenneth Hobs
06-28-2010, 07:16 AM
Private Sub CommandButton1_Click()
Dim r As Range
Set r = Range(RefEdit1.Value)
r.ClearContents
Unload Me
End Sub

YasserKhalil
06-28-2010, 07:28 AM
Thank you very much
But it has a debug if I used Ctrl key to select non-adjacent cells
I select A1 and e5 and F7 and I got the error runtime 1004

Bob Phillips
06-28-2010, 07:40 AM
Works fine for me. Is your worksheetprotected?

YasserKhalil
06-28-2010, 07:42 AM
No, my worksheets isn't protected
Try to select more than two ranges

Bob Phillips
06-28-2010, 08:40 AM
I did, I selected A1, E5 and E7 as you did.

YasserKhalil
06-28-2010, 10:23 AM
I got the following error

Kenneth Hobs
06-28-2010, 10:29 AM
Maybe you selected cells where some were merged?

YasserKhalil
06-28-2010, 10:46 AM
No merged cells in my sheet at all
I'm sorry for disturbing you
But I'm sure we will find a solution with you

Bob Phillips
06-28-2010, 10:47 AM
Post your workbook, and let's see if we get a problem with that.

YasserKhalil
06-28-2010, 10:57 AM
OK my dear
This is my workbook

Kenneth Hobs
06-28-2010, 11:21 AM
Your example worked fine for me.

YasserKhalil
06-28-2010, 11:25 AM
I'm using Excel2007 and Windows SP2 .. May be the version of the office or the Windows??
I try to solve it but I can't
Please help me!!

Kenneth Hobs
06-28-2010, 11:41 AM
Was it from a 2003 file? Try what was said in http://www.excelforum.com/excel-programming/681338-error-in-loading-dll.html:

In Tools -> References and I pointed on the "Missing: Ref Edit Control" and on the bottom of this box "Location:C:\Program Files\Microsoft Office\OFFICE12\REFEDIT.DLL" was. So on the other data I created the "OFFICE12" folder in to "Microsoft Office" and I copyed from my data the "REFEDIT.DLL" in to it. I have both Office (2003, 2007) and I used the 2007 "REFEDIT.DLL". And now is working fine. I wrote the MACRO in 2003, but it worked just with the 2007 "REFEDIT.DLL"

Bob Phillips
06-28-2010, 12:08 PM
I have just tried it on 2007 SP2, worked fine.