How to extract the first range from a refedit selection

Pookiemeister

Well-known Member
Joined
Jan 6, 2012
Messages
626
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
I am using the refedit control on my userform. Is there a way to extract the first range from my selection so I can offset it to retrieve other data from that row as well from "Sheet1" within workbook named "SDPF". Example: With the refedit, I am selecting the range(H1044:H1061). However, to extract the other pieces of data I just need the first selection, of H1044, so I can offset it to retrieve other data, in this case from Range(B1044), Range(C1044), Range(E1044), Range(F1044), and Range(I1044). Thank You
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Code:
Private Sub CommandButton1_Click()
  Dim r As Range, r1 As Range
  Set r = Range(RefEdit1)
  Set r1 = r(1)
  MsgBox r1.Address, , r1.Address(external:=True)
End Sub
 
Upvote 0
Thank you for the quick response. One question, instead of a message box how can I display the range in a textbox. I've tried:
Code:
Private Sub cmdbtnDone_Click()    Dim r As Range, r1 As Range
  Set r = Range(RefEdit1)
  Set r1 = r(1)
  textbox1.Value= (r1.Address, , r1.Address(external:=True))
End Sub
But I got a "Compile error: Syntax error". Thank You.
 
Last edited:
Upvote 0
You passed 3 parameters. "=" implies one assignment. Pick which string you want to show. e.g.
Code:
Textbox1.Value = r1.address
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,184
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top