![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Location: Jefferson City, Missouri
Posts: 383
|
When a user clicks a command button how would I write code that will check the number the user entered into a textbox to the same number in cells A8:A93 and then insert the value the user entered into another textbox in column D of that row?
TsTom, First thanks for all your help so far. I'm trying a different way to get what you've been helping me with. It's just to hard to explain what I'm trying to do with out you seeing my workbook. So, I figure if I can compare the two numbers then I can hopefully get it to do the other part as well. thanks,
__________________
I appreciate the help from everyone at Mr. Excel. viper |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
|
Hi Vip.
I gotta run... Textbox1 is the number to search Textbox2's value or text will be placed in Column D on the same row...
Tom |
|
|
|
|
|
#3 |
|
MrExcel MVP
Join Date: Mar 2002
Location: Kobe, Japan
Posts: 1,420
|
Hi viper,
If you need to show the value of textbox2, please try this.
_________________ With regards, [ This Message was edited by: Colo on 2002-05-14 23:35 ] |
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Feb 2002
Location: Jefferson City, Missouri
Posts: 383
|
Thank you TsTom worked great, now for the next part.
For Each c In Range("A8:A93") Debug.Print c.Value If c.Value = Val(TextBox1) Then Cells(c.Row, 4) = TextBox4 Exit For End If Next Now I need to check that cell "Cells(c.Row,4) = TextBox4" if it is not blank then I need to insert a row and enter the data into the new row 4th column. But only if the cell is not blank, if it is blank then insert the data into the cell. Then after that I need to have the Range("A8:A93") increased by one to be Range("A8:A93"). What I am trying to accomplish is this. I have the cells A8:A93 that contain a number 1-85 and the cell in column d will contain a figure for that number. When the user enters a number into the textbox1 (1-85) and then enters a figure into textbox4 the figure will be put into column d that matches the number the user entered into textbox1. But if the user enters the same number in textbox1 twice or more I need for a new row to be inserted so that it will keep more than one entry for each number (1-85). Right now all I can do is overwrite the data each time. If I enter number 1 into textbox1 and 15.00 into textbox4, the code puts 15.00 into row 8 column D because the number 1 is in Row 8 column A. But if I enter 1 again and 25.00 in the other textbox the code will overwrite the 15.00 with the 25.00, I need for it to be put under the 15.00 hence the inserting of a new row. If I am doing the hard way please someone slap me with an easier way. thanks,
__________________
I appreciate the help from everyone at Mr. Excel. viper |
|
|
|
|
|
#5 |
|
Board Regular
Join Date: Feb 2002
Location: Jefferson City, Missouri
Posts: 383
|
Thanks Colo,
__________________
I appreciate the help from everyone at Mr. Excel. viper |
|
|
|
|
|
#6 |
|
Board Regular
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
|
Hey Viper.
I don't know what you are doing, so I can't tell if there is a better way... For the time being, name your range so that when rows are added, the named range will automatically expand... In this ex. your named range for A8:A93 is "YourRange"
Tom |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|