| | |
Use TaxtBox value in Find function in VBA
Thread Solved |
•
•
Join Date: Apr 2008
Posts: 2
Reputation:
Solved Threads: 0
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.
# 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
# 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 *
So, Please do something before post your thread.
* PM Asking will be ignored *
•
•
Join Date: Apr 2008
Posts: 2
Reputation:
Solved Threads: 0
Thanks for the reply. I got the problem resolved using the following code:
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!
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Private Sub OK_Click() Application.ScreenUpdating = False ActiveWorkbook.Sheets("Amortization Table").Activate Range("C14").Select Range(Selection, Selection.End(xlDown)).Select Selection.Copy ActiveCell.Offset(0, 1).Select Selection.PasteSpecial Paste:=xlPasteValues Selection.NumberFormat = "m/d/yyyy" Dim rFound As Range On Error Resume Next With Sheets("Amortization Table") Set rFound = .Columns(4).Find(What:=TextBox1.Value, After:=ActiveCell, LookIn:=xlValues, LookAt:= _ xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _ , SearchFormat:=True) On Error GoTo 0 If Not rFound Is Nothing Then Application.Goto rFound, True End With ActiveCell.Offset(0, 7) = TextBox2.Value Range("A1").Select Call UserForm_Initialize frmPrinPmt.Hide ActiveWorkbook.Sheets("Enter Data").Activate Range("A1").Select 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!
![]() |
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Connection to MYSQL
- Next Thread: is it possible to passing text box value from one form to another
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age application basic beginner birth bmp calculator cd cells.find click client code college component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report save search sendbyte sites sort sql sql2008 sqlserver subroutine tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows






