Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default VBA UserForm Question.......Help!

Hi I was wondering if someone could please help me.....
On my UserForm i have 4 textboxes, i want to code it so when
TextBox1_Change() it will take the data entered into it ie(1234567)
searh a work sheet for the data entered and when found will return the
result of the cell in the next collum where the 1234567 was found IN
TextBox2 and if not found update TextBox2 with "Not Found"

Any help would be appriciated,
Thanks
Sam
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default VBA UserForm Question.......Help!

Something like:

Private Sub TextBox1_Change()
Dim rng As Range
On Error Resume Next
Set rng = Cells.Find(TextBox1, , , xlWhole)
If rng Is Nothing Then
TextBox2 = "Not Found"
Else
TextBox2 = rng.Offset(, 1)
End If
End Sub

--

Vasant

"Sam Torasco" wrote in message
m...
Hi I was wondering if someone could please help me.....
On my UserForm i have 4 textboxes, i want to code it so when
TextBox1_Change() it will take the data entered into it ie(1234567)
searh a work sheet for the data entered and when found will return the
result of the cell in the next collum where the 1234567 was found IN
TextBox2 and if not found update TextBox2 with "Not Found"

Any help would be appriciated,
Thanks
Sam



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default VBA UserForm Question.......Help!

Thanks,
Im on the right track now. but how do i tell it to search the data on
sheet2?

Sam

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default VBA UserForm Question.......Help!

Thanks,
Im on the right track now. but how do i tell it to search the data on
sheet2?

Sam

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default VBA UserForm Question.......Help!

Replace:

Cells.Find

with:

Sheet2.Cells.Find

--

Vasant


"Sam Torasco" wrote in message
...
Thanks,
Im on the right track now. but how do i tell it to search the data on
sheet2?

Sam

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default VBA UserForm Question.......Help!

Any help would be appriciated,

Well I assume that the point is "looking for the data" and not changing
Textbox2 value or detecting the _change event on box1

I think there many solutions

First:
using the Find method (see in the VBE help)
this does the same than the "CTRL+F" find manual method
You can check each Sheet by

For each Sh in Sheets
.....
next


Second:
using only loops, not necessary for you, but sometimes permit more complex
activity:
for each sh in sheets
for each cell in sh.cells
...
next
next


I hope this will help enought.


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default VBA UserForm Question.......Help!

Dim rng as Range
set rng = Cells.find(Textbox1.Value)
if not rng is nothing then
Textbox2.Text = rng.offset(0,1).Value
else
Textbox2.Text = "Not Found"
End if

see help on the find method for other arguments you may use to control the
search.

--
Regards,
Tom Ogilvy

"Sam Torasco" wrote in message
m...
Hi I was wondering if someone could please help me.....
On my UserForm i have 4 textboxes, i want to code it so when
TextBox1_Change() it will take the data entered into it ie(1234567)
searh a work sheet for the data entered and when found will return the
result of the cell in the next collum where the 1234567 was found IN
TextBox2 and if not found update TextBox2 with "Not Found"

Any help would be appriciated,
Thanks
Sam



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
Question regarding UserForm TotallyConfused Excel Discussion (Misc queries) 0 September 3rd 09 09:38 PM
UserForm Question Stockwell43 Excel Discussion (Misc queries) 0 October 27th 08 01:02 PM
Userform Question Greg B Excel Discussion (Misc queries) 3 March 10th 05 10:46 AM
Userform question David Goodall Excel Programming 1 May 16th 04 03:25 PM
userform question David Goodall Excel Programming 0 August 25th 03 07:10 PM


All times are GMT +1. The time now is 02:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"