ابزاری برای انتخاب ک محدوده از سلول ها VBA
برای انتخاب یک محدوده از سلول ها می توان از ابزاری بنام REFEDIT استفاده کرد.
TextBox1 = RefEdit1.Value
مثال : در یک فرم سه شیء TEXTBOX , REFEDIT, COMMANDBUTTON قرار دارند فرض کنید قصد داریم آدرس انتخاب شده توسط REFEDIT را با فشار دادن کلید در TEXTBOX نمایش دهیم در بخش کد مربوط به کلید متن زیر را وارد می کنیم :
()Private Sub CommandButton1_Click
TextBox1 = RefEdit1.Value
End Sub
راهنمای اکسل
RefEdit Control
On a user form, this control displays the address of a range of cells that you've entered or selected on one or more worksheets. To select a range, click the button in the control to collapse the user form, select the range, and then click the button in the control again to expand the user form.
If the RefEdit control is embedded on a worksheet, you can link the contents of the control to a cell on any worksheet in that workbook.
Remarks
The default property for a RefEdit control is Value.
The default event for a RefEdit control is BeforeDragOver.
You cannot use a RefEdit control on a modeless user form. You can use the ShowModal property to set a user form to modal.
Example
This example sets the control tip text for the RefEdit1 control in UserForm1, and then it displays the user form.
UserForm1.RefEdit1.ControlTipText = _
"The selected range of data in the worksheet"
UserForm1.Show
Later, the user clicks CommandButton1 in UserForm1. This example of an event-handling procedure displays the address of the selected worksheet range and then ends the program.
Private Sub CommandButton1_Click
MsgBox RefEdit1.Value
End
End Sub
+ نوشته شده در چهارشنبه یکم اسفند ۱۳۸۶ ساعت 9:37 توسط علی توضیح
|