Use TaxtBox value in Find function in VBA

Thread Solved

Join Date: Apr 2008
Posts: 2
Reputation: glfnfvr is an unknown quantity at this point 
Solved Threads: 0
glfnfvr glfnfvr is offline Offline
Newbie Poster

Use TaxtBox value in Find function in VBA

 
0
  #1
Apr 17th, 2008
I am trying to write a code that asks for a date in a user form text box and then takes that date and looks for it in a range. Once it finds that date I want to enter the data from the second text box in a cell on the same row. I can't seem to get the find function to work using the textbox value. Can anyone help me figure out a way to make this happen? If you need a better explanation of the problem/desired result please let me know! Thanks in advance for any help you can provide.
Last edited by glfnfvr; Apr 17th, 2008 at 7:37 pm.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 122
Reputation: cometburn is an unknown quantity at this point 
Solved Threads: 19
cometburn's Avatar
cometburn cometburn is offline Offline
Junior Poster

Re: Use TaxtBox value in Find function in VBA

 
0
  #2
Apr 17th, 2008
Why not use a date picker instead?
Proud to be Philippine made...
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: Use TaxtBox value in Find function in VBA

 
3
  #3
Apr 17th, 2008
# To add a Date Time Picker control, on the Toolbox, click the More Controls button
# Scroll down in the list of controls, click Microsoft Date and Time Picker 6.0 (SP4), and click the form.
see this tutorial
Last edited by Jx_Man; Apr 17th, 2008 at 11:27 pm.
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 2
Reputation: glfnfvr is an unknown quantity at this point 
Solved Threads: 0
glfnfvr glfnfvr is offline Offline
Newbie Poster

Re: Use TextBox value in Find function in VBA

 
0
  #4
Apr 18th, 2008
Thanks for the reply. I got the problem resolved using the following code:

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub OK_Click()
  2.  
  3. Application.ScreenUpdating = False
  4.  
  5. ActiveWorkbook.Sheets("Amortization Table").Activate
  6.  
  7. Range("C14").Select
  8. Range(Selection, Selection.End(xlDown)).Select
  9. Selection.Copy
  10. ActiveCell.Offset(0, 1).Select
  11. Selection.PasteSpecial Paste:=xlPasteValues
  12. Selection.NumberFormat = "m/d/yyyy"
  13.  
  14. Dim rFound As Range
  15.  
  16. On Error Resume Next
  17. With Sheets("Amortization Table")
  18. Set rFound = .Columns(4).Find(What:=TextBox1.Value, After:=ActiveCell, LookIn:=xlValues, LookAt:= _
  19. xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
  20. , SearchFormat:=True)
  21.  
  22. On Error GoTo 0
  23. If Not rFound Is Nothing Then Application.Goto rFound, True
  24.  
  25. End With
  26.  
  27. ActiveCell.Offset(0, 7) = TextBox2.Value
  28.  
  29. Range("A1").Select
  30.  
  31. Call UserForm_Initialize
  32. frmPrinPmt.Hide
  33. ActiveWorkbook.Sheets("Enter Data").Activate
  34. Range("A1").Select
  35.  
  36. End Sub

the problem was with the find section, but when I added the Dim rfound As Range and the With and error handling it worked fine.

While this works I will still try the date picker to see if it would be better/easier. Thanks again for your help!
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC