Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 16th, 2004, 04:54 PM
Registered User
 
Join Date: Feb 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Finding a matching value

Hello people,

I am having a little trouble.

I am trying to write an if statement into my submit button that will match the number that is in a text box on my form with a number listed in column G of a sheet.

On my form there are three text boxes and a submit button. In column G of my sheet i have a list of part numbers. When i press the submit button i want it to locate the number in column "G" on the sheet that matches the number in the text box (DPartNum.Text) and then place an * in column "O" of the same row that the number was found in column G.

Below is the code that i have tried to create.


Private Sub Submit_DNotes_Click()

With Worksheets("Notes")

Worksheets("Notes").Range("1:500").Rows.AutoFit
cLastRow = .Cells(Rows.Count, "F").End(xlUp).Row
.Cells(cLastRow + 2, "F").Value = "Change Number: " & ChangeNum.Text
.Cells(cLastRow + 3, "F").Value = "Part Number: " & DPartNum.Text
.Cells(cLastRow + 4, "F").Value = " " & DNotes_Box.Text

End With
If DPartNum.Text = Worksheets("Disposition").Range("G1:G500") Then
Worksheets("Disposition").Range("O").cols.Insert ("*")
End If

DNotesForm.Hide
ChangeNum.Text = ""
DPartNum.Text = ""
DNotes_Box.Text = ""
End Sub


The With statement is a different function that the button performs.

Thank you
Morry



 
Old March 16th, 2004, 06:24 PM
Authorized User
 
Join Date: Oct 2003
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try this instead of your if

dim i as integer
for i=1 to 500
     if worksheets("Disposition").cells(i,"G")=DPartNum.te xt then
        worksheets("Disposition").cells(i,"O")="*"
        exit for
     end if
next



 
Old March 26th, 2004, 05:32 AM
Authorized User
 
Join Date: Oct 2003
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Let us know! Did it work?
Selby







Similar Threads
Thread Thread Starter Forum Replies Last Post
Regex and Alphanumeric matching? quantass BOOK: Beginning Regular Expressions 0 March 10th, 2007 11:34 AM
Finding matching rows on two worksheets Wire323 Excel VBA 0 April 13th, 2006 12:11 AM
Matching two strings jamie_t VB How-To 0 October 12th, 2005 03:40 AM
ADODB Finding matching records rjp Access VBA 0 August 25th, 2004 07:47 PM
Matching between two sibling nodes AForgue XSLT 5 November 26th, 2003 11:05 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.