View Single Post
  #16   Report Post  
Posted to microsoft.public.excel.programming
Art Art is offline
external usenet poster
 
Posts: 587
Default Refer to first cell in range

I get this error for this code:

If Categories.CheckBox1 = True Then
Dim rngAddr As String, myCell As String
rngAddr = Me.RefEdit1.Value
myCell = Range(rngAddr).Range("A1").Address
Range(myCell) = TextBox1.Text
End If

Run time error 1004 method Range of object global failed. Why is it not
good? Please help.

"JLGWhiz" wrote:

OK, I got it now. The only thing is that after a user chooses a range
through the RefEdit and then closes the form, the value of the RefEdit is
also gone. You would have to capture the RefEdit value in a variable while
the form is open and pass that variable to your other code to be able to work
with it later. I think Rick gave you some code that would work while the
form is still open. Here is some more that will work while the form is open.
You can put it in a click event somewhere on the form, button or any control
including the form itself.

Dim rngAddr As String, myCell As String
rngAddr = Me.RefEdit1.Value
myCell = Range(rngAddr).Range("A1").Address
Range(myCell).Select



"art" wrote:

I'll explain. The user selects a range say from A1:A25 thru the refedit. Then
I do something with the range. But then I need to do something with the first
cell in the range (A1) so how can refer to thta? Am I clear enough?



"JLGWhiz" wrote:

Sorry, my eyes are going bad. You did specify range. I still don't
understand the question.



"art" wrote:

Hello:

I have a userform with a refedit. I need to refer to the first cell (top) in
the rnage how can I refer to it?

Also How can I retrict the user to select only 1 column at a time, meaning
he can select a range from column C from row 1 to row 10000... but he cannot
also select C1 to D5?

Thanks