Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Pick cell and populate userform

Here's what I'm trying to do: I have a userform that contains a textbox and a commandbutton. The user would have the option of either to type the data required in the text box or to click the commandbutton to hide the userform and look for the data in one of the sheets of the worksheet. Once the desired data is found in the sheet, the user would click (or doubleclick) on that cell and then the userform textbox would be populated with the contents of that same cell. Is there a way to do something like this? I appreciate any help from the Excel gurus..

Thanks, Alex.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Pick cell and populate userform

You want a RefEdit control, not a Textbox.

Create a new userform, drop a RefEdit control onto it. VBA will hopefully
name it RefEdit1. Add this code:

Private Sub RefEdit1_Change()
Static blnUpdating As Boolean
Dim rng As Range

If Not blnUpdating Then
On Error Resume Next
Set rng = Range(RefEdit1.Text)
If Not Err.Number Then
blnUpdating = True
RefEdit1.Text = rng.Value
blnUpdating = False
End If
On Error GoTo 0
End If
End Sub


You wont be able to type text which resolves to a Range. eg. Typing A1 will
end up copying the Value in cell A1 instead.
Let me know if that's going to be a problem?


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Alex" wrote in message
...
Here's what I'm trying to do: I have a userform that contains a textbox

and a commandbutton. The user would have the option of either to type the
data required in the text box or to click the commandbutton to hide the
userform and look for the data in one of the sheets of the worksheet. Once
the desired data is found in the sheet, the user would click (or
doubleclick) on that cell and then the userform textbox would be populated
with the contents of that same cell. Is there a way to do something like
this? I appreciate any help from the Excel gurus...

Thanks, Alex.



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
how can i re-populate a userform with data already entered? Paul Dye New Users to Excel 1 January 24th 07 04:49 AM
Populate a cell with a date using calendar pick Shane Nation Excel Discussion (Misc queries) 2 January 29th 06 07:48 PM
create a userform to populate a diagram with the forms info Mic Excel Discussion (Misc queries) 0 July 22nd 05 08:07 PM
Userform using 3 ranges to populate. Todd Huttenstine[_2_] Excel Programming 1 December 13th 03 12:33 AM
Range of Cells to populate in a text box on a userform BenjiHarshbarge Excel Programming 1 November 4th 03 10:09 PM


All times are GMT +1. The time now is 05:51 PM.

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"