VBA - Search Unique Code And Enter Data In Respective Row
May 18, 2013
I have a problem to write a VBA code for the following task:
My worksheet has a column that has a unique code in column C (Ex: HR1) which is not repeated throughout column C, and I need to insert the amount of money spent on this specific code.
I would run a userform that has two text boxes, one that I shall enter the unique code and the other text box shall be the amount of money spent. I would like to know of a vba code that can search the unique code of the value entered in the first text box of the userform, then to enter the amount of the second text box into column D in relation to the respective row which the unique code is located.
I would like that the amount entered in column D regarding the unique code could be added automatically by entering any new entries in relation to the unique code selected, if this is possible. If not possible, to go inserting any new date into the next column regarding the same row of the unique code.
Ex:
A
B
C
D
[Code].....
View 2 Replies
ADVERTISEMENT
Sep 9, 2003
I'm from Bavaria, Germany. Right now, I am doing an internship for my studies. my problem: I need a search procedure which shows an Input Box where you can enter a word to search for. It should work like the original Excel search (Ctrl-F), but with a simpler design, like with my own Text "Enter your Query" and a Button "Submit Query" / "Quit search". Is there the possibility to Highlight the Search Target? The problem hereby is that this highlighting should not be permanent. That means the user sees the target for which he searched for, the cell highlighted in a different color, etc. But as soon as the user clicks onto another cell, etc., the highlighting vanishes. If there is no fitting match, there should be a MessageBox like "Sorry the Target xyz cannot be found"
View 9 Replies
View Related
Dec 26, 2013
I have a spreadsheet where a date is entered in column A with data in B-F. I am trying to write code to look in column A for a specific date and enter additional data into columns G-L on the same row. It needs to be able to skip the rows that are blank. So I have the dates of 12/1, 12/2 and 12/3 in column A rows 1,2 and 3 and I want to enter data for 12/2 on row 2 skipping the blank cells in row 1 for 12/1. Here is the code I have below.
VB:
Private Sub CBSecure_Click()
Dim my_name As String
Dim r As Variant
Dim l As Long
sFind = DockDoorCal.Value
If Trim(sFind) = "" Then Exit Sub
[Code]....
View 4 Replies
View Related
Jun 11, 2013
Basically, in the "Thisworkbook" code , i have some code in the Workbook_BeforeClose section. Currently , it autosaves the workbook in a folder i have specified.
However, i need to add some code.I want to check that a certain cell has a value in it before the user closes the workbook, and if the cell is empty, show a messagebox asking him to enter a value.
I know how to get a messagebox to pop up, the only thing is once the user clicks the OK button,
i need the rest of the code execution to pause, allowing him to make the change then if he clicks the "X" (top right of the screen) to close the file or application, the filesave dialog appears and he can then save the document.
how to go about this because at the moment when user clicks ok, the messagebox just disappears and filesave dialog appears and he doesn't have a chance to edit the cell.
View 5 Replies
View Related
Apr 20, 2009
I am trying to display a message box for the user if there is "agency" in cell o8 but nothing in p8... I tried the following code but it doesnt work..
If Range("o8").Value = "Agency" And Range("p8").Value = "" Then
MsgBox "Please provide name of agency in cell p8"
Sheet9.Shapes("cross").Visible = True
Else
View 9 Replies
View Related
Apr 4, 2014
I want some code on how to fetch data from an Excel Database and display it on respective textbox.
Like I have these coloum name in excel sheet; Emp Id
Name
DOB
Dept
Reporting to
Transport req.
I want to have VBA code to fetch it on txtbx1, txybx2 and so on.
View 1 Replies
View Related
Jun 2, 2008
Now what I am looking to do is search my spreadsheet for specific criteria and then copy and paste these rows of information to a new sheet.
In my first spreadsheet that I am using as a database, I want to be able to select any entry from the month and copy it to another spreadsheet named for that criteria.
In other words, I want to find every entry for January, copy just that data's rows and paste them to the January spreadsheet, February to February, etc. My date fields are in column A.
I also want to do the same with representatives names found in column B.
This will break down the data for each rep and each month. Using the filter, then copy and pasting would be cumbersome.
View 9 Replies
View Related
Jun 1, 2014
I really know nothing about vba so here goes. I would like to enter data in a row with 4 cells of info. then hit enter and return to the first cell and move the row down. all four cells must have data entered. and all four must move down. i tried some code as below i found and i modified but it did not work as expected. this moved the row down when returning the cursor to A2. It also should not copy the data style of the top row.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column <> 1 Then Exit Sub
Application.EnableEvents = False
[Code].....
View 4 Replies
View Related
Jul 26, 2006
I have a userform that with a combobox called "complaintdis". This combobox displayes all the records in column A of worksheet "ComplaintData". When user selects any record from that dropdown list, it populates the other related fields on labels on the same userform. This part is working fine.
when user is looking at any displayed record on the userform (displayed via labels), I want user to be able to add comment that will get added to the column J of worksheet "ComplaintData".
I can workout a way to send this input data from textbox (called "txtcloser") to the column J, but I am struggling to figure out a way to link that comment to the specific record.
As there are number of entries in the worksheet "ComplaintData" , user should be able to select any record (via combobox) in no specific order and leave a comment.
View 9 Replies
View Related
Jul 19, 2006
When i press say a command button " Add Repair Information" i want the User to Enter the serial number which i have given it a range called SerialN from the excel sheet and enter a repair action. Is there a function in Excel which will allow me to search the Serial Number and allow me to put the Repair action across in the cell on the same line?
View 5 Replies
View Related
Jun 18, 2013
So this is what I am trying to do, I have a column in my data that is for telephone numbers. When I receive the file some of the fields are blank in that column. I need to add to my current macro a part that evaluates the column for blanks and adds a static telephone number in the blanks (up to the last row of data in the file). I have been able to accomplish this with the following:
Range("N2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.FormulaR1C1 = "1112223333"
However, when the file that I receive has a telephone number in all the fields the code breaks at this point. I have tried On Error Resume Next, but that just replaces all the remaining cells in the column with the static 1112223333..
View 3 Replies
View Related
Jul 14, 2007
I want to enter a value in a textbox, search for it in an worksheet, and populate other textboxes with adjacent values if the value is found. Anyway, the problem is that if the value is not found, I get a debug error.
Dim test1
test1 = TextBox1.Value
Worksheets("data1").Activate
Find_Range(test1, Cells, xlFormulas, xlWhole).Select
TextBox2 = ActiveCell.Value
TextBox3 = ActiveCell.Offset(0, 1).Value
I'm sure there's far better code to do what I need, but I tried to keep it simple. With the above code, it only works if the value is found. If it's not, I get an error. So how do I make it so that if the value is not found, the value of the textbox2 is "Not Found" or something...
View 3 Replies
View Related
Oct 9, 2008
Probably this is a simple question but I am still in a learning curve:
I have a table as the example below, I need a formula for colum C where the all results for a given depth are display one after the other.
DEPTHRESULTRESULTS AT 3m0346713569256553673447857968057647536925012000134244355467569670572445334223115
View 9 Replies
View Related
Nov 28, 2009
I have a formula for counting unique text records. However, is it possible to count unioque records based on certain conditions. For example, I have a stats sheet for a sports league and I want to count all the unique teams for dsivision 'North'. Coloumn A has the division, coloumn B has the team they played on that day.
I want to count all the unique records in column B, but based on those teams being in the 'North Division' (column A)
I want to do this with Excel, and not in VBA.
My formula for finding unique records is:
View 9 Replies
View Related
Dec 14, 2011
How would I set up a formula that can search for a unique identifier if the unique identifier is not know.
I would like to set up this formula in Tab 1 where it looks to column A in Tab 2, which is a column of about 600 unique identifiers, to find any cells containing the string "VA". There will be multiple cells that include "VA" in the string
I would like this formula to collect all the cells in the column A in Tab 2 into a column of cells in Tab 1 beginning in Cell A5. I would copy the formula in Cell A5 of Tab 1 down multiple lines. I can add a segment to the formula that will return a blank if there are no more cells with the indicated string included.
Tab 1 formula begins in Cell A5Tab 2 of Unique IdentifiersFormula that will copy first cell in Tab 2 that includes VA in the string from Tab 2VANewsprint23005-2119Formula that will copy next cell in Tab 2 that includes VA in the string from Tab 2TNPackaging37309etcALPackaging35044etcVAPackaging24526-0040etcONPackagingP0K 1E0NHPackaging03743VAPackaging24521NYPackaging13667MIPackaging49099VA
Packaging24426ONPackagingM1P2Y9ONPackagingM1P 2Y9WIPackaging53512-0386MIPackaging49042VAPackaging24504
View 1 Replies
View Related
Jun 10, 2007
I am "designing" a time- tracking database. The way it works is that each user (there are multiple users) creates a new day, which is mirrored in the sheet name (i.e. if today is 06/09/07 and my name is Newuser, the sheet name is "NewusER 060907"). Each sheet is filled in, calculated based on in-sheet formulas, etc. At the end of said day, the user can " upload" the daily data from multiple days worth of data into another sheet, that the graphing macro draws from.
The one serious problem I'm having is that users can upload the daily time data for the same day multiple times, to no end. I would like to do one of two things. Either:
a. make it such that once data is uploaded it cannot be uploaded again (probably more difficult), or
b. write a loop to pull out the highest data point up the sheet and delete all other rows for that one specific day's . (probably easier)
example:
Data loaded into the sheet before the macro runs:
Row: Date:
1 06/09/07 *
2 06/10/07 *
3 06/11/07 *
4 06/09/07
5 06/10/07
6 06/12/07 *
7 06/13/07 *
8 06/09/07
9 06/11/07
10 06/14/07 *
* The rows with asterisks are the ones that I would like to have pulled to the second set of data (below)
Data in the sheet after the macro runs:
Row: Date:
1 06/09/07
2 06/10/07
3 06/11/07
4 06/12/07
5 06/13/07
6 06/14/07
Because of the constant changing nature of the information within, I would like to to make this dynamic range selection, I would prefer to avoid using Advanced Filters, if possible.
View 6 Replies
View Related
Mar 26, 2013
My workbook contains a input sheet and multiple sheets with the data I compile. In the examples I provided, on each sheet "Server Name" is unique data to each sheet. I would like to have the ability on the Input sheet to click one of the server names and that take the user to the record on sheet 2. Not sure iif I need to be looking at a Macro or a formula to do this.
View 1 Replies
View Related
Apr 8, 2014
I need a code to enter 2 blank rows at each change in data in column B with totals entered at the end of columns E-J.
I have attached a sample with a before and after tab.
View 3 Replies
View Related
Dec 16, 2009
i have 15 textboxes in my userform (all with tags).
instead of having 15 seperate sub routines that call on one macro is there a way i can write some code that, on entering any texbox within a form, a specific routine would be called
i tried using the Userform_click sub like so, but with no joy:
View 7 Replies
View Related
Mar 9, 2009
I need vba code to retrieve the workbook name and place it into macros. the workbook name does not change in the macro if the name of the workbook changes. so i need to assign the name to a variable then use the variable name as the workbook name............
View 9 Replies
View Related
May 29, 2014
I have a workbook that I'm using to tracking staffing patterns within a mental health agency. When the workbook opens the user is asked to pick a date range and an office location. I've placed code into the userform that pre-fills the "start date" with today's date and the "end date" 7 days from today's date. I would like the user to be able to enter a unique date range should they wish but I have yet to figure out the coding to accomplish my goal.
[Code] .....
Attached File : Staffing Report 1.90.xlsm
View 7 Replies
View Related
Apr 10, 2008
I have a ton of cells that contain formulas with arrays. How can I update these without:
clicking the cell
clicking the formula bar
then hitting CTRL+SHIFT+ENTER
View 13 Replies
View Related
Aug 10, 2013
I have a problem here regarding the combo box. The whole Column A has combobox. It would be easier if by just hitting the TAB or Enter it would go to the next cell just like what is usual in excel.
TAB = next cell to the right
Enter = Next cell below
View 1 Replies
View Related
Mar 3, 2009
i have an excel sheet where i enter company information including Zip code. the zip codes around here all start with 797 and end with numbers from 01 to 12
i am looking for a way to enter just the last 2 numbers and have it automatically insert the full zip
example:
line one i would enter 01 and 79701 would show up in the box.
I know there are ways to do this, just can't remember its been so long since I've had to use excel.
View 9 Replies
View Related
Jun 11, 2009
i would like to create a userform with a textbox to enter a product code , a command button to run VBA and a big text box to show output of VBA from Textbox 1 which i will connect to DB and pull back information relevant to that product code , is this possible i can create the userform no problem and already have code to pull back from DB into Excel ,
View 9 Replies
View Related
Apr 23, 2008
I'm trying to enter a series of formulas referencing the first cell of each row.
With Range("A40")
Range(.Cells(1, 1), .End(xlDown)).Offset(0, 1).FormulaR1C1 = "= COUNTIF(Details!R2C2:R65536C2,RC1)"
Range(.Cells(1, 1), .End(xlDown)).Offset(0, 2).FormulaArray = "=RC[-1]-SUM((Details!R2C2:R65536C2=RC[-2])*('Details'!R2C11:R65536C11=RC1))"
Range(.Cells(1, 1), .End(xlDown)).Offset(0, 4).FormulaArray = "=SUM((Details!R2C2:R65536C2=RC1)*(Details!R2C4:R65536C4>TODAY()-7))"
Range(.Cells(1, 1), .End(xlDown)).Offset(0, 5).FormulaArray = "=RC[-1]-SUM((Details!R2C2:R65536C2=RC1)*(Details!R2C11:R65536C11=RC1)*(Details!R2C4:R65536C4>TODAY()-7))"
Range(.Cells(1, 1), .End(xlDown)).Offset(0, 7).FormulaArray = "=SUM((Details!R2C2:R65536C2=RC1)*(Details!R2C4:R65536C4>TODAY()-30))"
Range(.Cells(1, 1), .End(xlDown)).Offset(0, 8).FormulaArray = "=RC[-1]-SUM((Details!R2C2:R65536C2=RC1)*(Details!R2C11:R65536C11=RC1)*(Details!R2C4:R65536C4>TODAY()-30))"
End With
While this code works for the first formula, the following 4 are arrays, and for some reason, will only reference the first A40 cell.
View 9 Replies
View Related
Feb 25, 2013
I have some VBA code which hides columns based on a cell value. The cell value changes according to which option button is selected. The code works but not when the button is selected and the cell value changes. It is necessary to click elsewhere in the sheet or press Enter to get the columns to hide. I want it to do it automatically as a user wouldn't know to click elsewhere.
The working code is:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("N5").Value = 2 Then
Columns("O:R").EntireColumn.Hidden = True
Else
Columns("O:R").EntireColumn.Hidden = False
End If
End Sub
N5 is the linked cell for the option button.
View 4 Replies
View Related
Jul 17, 2014
I'm trying to get certain Excel cells (varies by column and row) to populate different areas in a Word document. I've tried using both Word bookmarks and form fields and have defined the Excel names with the Word bookmark names as well as using Word's generic terms (Field1, Field2, etc.) with no luck. The VBA code I'm using now is for word forms and will open the Word document but seems to delete the form fields. I don't know if I'm not coding the cells correctly or what.
Sub CreateProposal()
Dim wdApp As Word.Application
Dim wdDoc As Word.Document
Set wdApp = CreateObject("Word.Application")
' Open word document
[Code] ........
View 3 Replies
View Related
Jun 15, 2014
well, the clear worked well and now I have another idea for a button for my worksheet;
I want the button to insert values from other cells. so when it is clicked, the values in cells F82-F86 are entered in cells E19 - E23.
View 5 Replies
View Related
May 8, 2013
I have produced a basic search/lookup facility on an Excel workbook that simply allows the user to enter a post code and some details will be returned using a vlookup. The document is going to be rolled out to a number of operational users so I want to basically 'lock down' everything I can in the document (basically everything except the data entry cell) and make it fool proof- I have locked all cells apart from the data entry cell and have made the file read only.
The only issue I am encountering is when the cursor is in the one 'unlocked' cell (i.e. the one the users will enter the post code into); it appears that you can break the document. For example, when the cursor is in the 'unlocked' cell, I am able to go to Tools > Options and change various settings including cosmetic colour changes but also cell calculation which breaks the lookup functionality. This is probably enabled as the cell is unlocked, but if I lock the cell, when I protect the document, it disables data entry!
if there is another way of providing this one cell for users to input data into for the vlookup to work whilst locking down the rest of the document to ensure that no-one can break it?
View 1 Replies
View Related