Lookup Via Macro Code: Find The Match And Then Select That Cell In VBA

May 24, 2008

I have a large database of equipment on one sheet and an input form on another. For inventory control, when a user scans a number into the input form, the main inventory sheet is updated with the current location. I have it working using functions, but I need to do this in VBA. I am looking to do the following;

User enters 2222 on the input form. The code matches 2222 on the inventory sheet, moves the activecell 10 columns and updates a value in that cell. Cell A2343 is "2222" then Cell K2343 is changed to "WAREHOUSE 4". What is the best way to find the match and then select that cell in VBA?

View 8 Replies


ADVERTISEMENT

Find & Return One Of Many Values In Cell & Lookup Corresponding Match

Dec 10, 2007

Working on an export from an e-commerce application that lists the item purchased, unfortunately not by item #, but rather a lengthy description. I'm trying to construct an item number based on that description which contains several constants.

Each item ordered appears in a single row, comprised of ORDERID, QTY, PRODUCT DESCRIPTION

I have several tables to pick out PRODUCT TYPE, COLOR, SIZE, etc. I need a formula to search to see which of the unique values appears in each in the cell and return the shortcut of that value.

PRODUCT DESCRIPTION example "Sweater - Blue - Large - Wool"

TYPE TABLE:
Sweater SWTR
T-Shirt TSHT
Jeans JEANS

COLOR TABLE:
Blue BL
Green GN
Purple PL
Black BK

I would have separate tables for each part of the description.

The formula I'm seeking would search the PRODUCT DESCRIPTION cell for the range of values for each 'part'. So it would search to see which of Sweater, T-Shirt, or Jeans was in the cell and then return the one that was - SWTR in this example. I would modify this formula for each 'part', in its own cell, and then use an =cell#&"-"&cell#&etc... to combine these returned values.

I know I can write a large if- chain using ISERROR & FIND, though some of these lists will get lengthy.

View 9 Replies View Related

Macro- Find Cell, Select That Row, And The One Beneath It

Feb 19, 2008

When recording a macro, how would I have it record me searching for a word in a cell, then select the two rows beneath it so that I can hide/unhide the hidden rows?

The reason it has to search for the word in the cell is that with changes above, the rows keep getting bumped further and further down (i.e., a moving target).

View 9 Replies View Related

Find And Select Match

Nov 12, 2009

I have a sheet with dates on it, when i open my userform and select a date i want it to go to the sheet and look for a match on the date and select the cell where the match is. There will never be 2 dates that's the same. I have attached an example.

View 2 Replies View Related

Macro To Find Matching Text In A Range And Select Specific Cell

Oct 18, 2013

I have a client list in a table in my excel sheet. I currently enter the clients in a sheet that looks similar to a form. After the clients info is in this Form I have a button with a macro to copy the client info into a table on another sheet. This works perfectly.

Now I have another form that will retrieve the customers info in a click of a button in order to make changes to the client. Ei:I now have a second phone number and I want to update that client's info. What I want to do from here is take the info in Cell B2 (clients full Name), Do a vLookup in the "Saved Clients Table" in a Range within my table range. (Range: Saved Clients and the client's full name is in $A:$A and called "Clients Full Name" and once that name is found I need to select the cell in column C and the corresponding row.

This will allow me to copy the info in my form, Paste it in Transpose to the cell that is selected. (I already have that code)

Here are screenshots of what I am trying to accomplish. [URL] .......

View 3 Replies View Related

Add VLOOKUP To Cell (Macro Code) & Offset From Range For Lookup Value

May 27, 2008

I'm trying to use an offset from a Named Range as my source cell in a vlookup but get a -1004 Object not defined error. When Debugged the Range.Formula appears to be blank when queried. Using Record a Macro the Reference to a named range worked fine but I could not test for an offset or the use of the range reference. What can I do to use to make this work

Range.Formula="=vlookup(Range(""SomeName"").Offset(1,0),DataRange,2,False)"

View 7 Replies View Related

Lookup - Match - Find - Offset

May 2, 2006

on sheet 1
I have a list of race car numbers (20K, 15W, 2) in A1:A50 (may be more or less than 50)
Next to them in B1:B50 are the point values they earned for a night of racing. 100-97-94 etc.... these are points they have earned for a night of racing that week.
in C1 I have how many column over I need to write to (ex. 4 for Column "D" on sheet 2)

On sheet 2 I have all the total for each week.
example
A1 B1 C1
Car 4/22 4/29
20K 94 90
15W 97 100
......

What I need is some code to go down the driver list on sheet1 and write their points in colum D on sheet 2 when it finds the appropriate car number. If the car number does not exist then add the car to the bottom of the list (A50) or whatever, and write the points 4 columns over.

View 6 Replies View Related

Macro To Find Match Delete It From The Cell Display It In Different Cell

Apr 23, 2008

I have a huge database. I am looking for a macro that can search for a particular word. If a match is found, the macro should do two things simultaneously... (i) delete the contents of the cell in which the match is found........(ii) display the same contents 1 row below and 1 coloumn to the left of this cell where the match is found. For e.g....

View 9 Replies View Related

LOOKUP / MATCH Function To Lookup The Owner Name Typed In Cell

Jan 2, 2009

I have a workbook with 2 different types of sheet - 1 containing source data and the others 'collecting' data from the source sheet, depending on what the sheet is for.

For example, the data source contains different pets, their names, ages and their owners.

The other sheets are on a one-per-owner basis.

What I would like to do is use a LOOKUP / MATCH function to lookup the owner name typed in cell A1 of the output sheet and match it with the corresponding owner name(s) on the source sheet. I would then like it to return with each pet and append the results on the sheet accordingly - like below:

John Smith (in cell A1)

Pet - Name - Age
-------------------
Dog - Rover - 3
Goldfish - Tom - 1
Gerbil - Chewit - 4

View 7 Replies View Related

Macro To Find A Cell Containing Text /select Range Offset / Cut And Paste To Lower Rows?

Feb 4, 2014

I am trying to find a macro that can search a sheet for any cell that contains the text "Not on AOI" selects a range that contains that cell, 81 rows below, and 2000 columns to the right, then cuts the selection and pastes it 162 rows below the original cell where the text was found. What's hard is that the number of columns between the "Not on AOI" cells is variable.

I'm very new to excel macros and the parts I think I've put together are:

Cells.Find("Not on AOI", After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=True).Activate

[Code].....

View 1 Replies View Related

Find In VBA Code: Find Exact Match

Oct 9, 2006

I'm using the below VBA

Dim c, DataRow
With Data
Set c = . Range("A5:A350"). Find(KPI, LookIn:=xlValues)
If Not c Is Nothing Then
DataRow = c.Row
End If
End With

Now,If KPI is for example = "Favourite Hotel" and if i have data that looks like :

Favourite Hotel - London
Favourite Hotel - Cardiff
Favourite Hotel
Favourite Hotel - Birmingham

Then it seems to not look be looking for an exact match (e.g. Favourite Hotel) and rather is finding the first item in the list that contains the KPI string (E.g. Favourite Hotel - London).

How do i make it search for an exact match?

View 4 Replies View Related

Macro Code: Find Cell Or Row Multiple Criteria

Sep 14, 2006

I can't seem to find the answer to this. In VBA, how do you Find a cell or row based on multiple criteria? All I need is to find it's location. If it helps, here's an example:

Sheet 1 contains source data:
Date Name Time Complete

Sheet 2 contains an interactive worksheet using this data. On Sheet 1 there's an entry: 9/12/2006 George 03:30 PM

Sheet 2 displays those records with adjacent cells for entering data. When data is entered, I need the system to go back to Sheet 1, find the entry that matches this one, and put an "x" in the Complete column.

View 6 Replies View Related

Macro Code To Find Blank Cell In Column

May 30, 2008

Short and simple. What is the quickest, easiest & most efficient way to find the first blank cell within a column using VBA?

View 9 Replies View Related

Find Text/Value & Use Found Cell, Row, Column In Macro Code

May 10, 2008

I am trying to clean up and simplify my macros by compartmentalizing frequently repeated commands. I like to search for text in column headings and define the cell containing it as a range that I can later use .column or .row commands on, so my macros are a bit more flexible. The code I currently use for this is

Dim XColumn As Range ‘the cell containing the text “X”
Cells.Select
Selection.Find(What:="X", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Set XColumn = ActiveCell

I would like to be able to create a Macro (possibly name FindSetCell()) that will accept arguments and achieve the results of the above code in other macros
I think the command might look something like FindSetCell(“text to be searched for”,”name of newly Defined Range”) But I have not figured out how to code it

View 2 Replies View Related

Macro Code For Select All

Jul 22, 2011

I record macro and hit select all and that action won't record. what's the macro code for select all in excel. i assumed it was the same as word

selection.wholestory

but it's not

View 7 Replies View Related

Find Then Select Row Macro

Aug 27, 2009

Is there any way to create a script or macro to "find" a number from column A that is in column B, then select it that row? Then it willl repeat that process with the next number in column A until the end....

View 14 Replies View Related

Select Range Macro Code

Apr 17, 2008

I have made a sheet where the user can insert/delete rows in a certain intervall of rows. The upper row is 17, that is I have named the cell "First" and then the last row "Last" and then I am using integers:

Dim intStartrow As Integer
Dim intLastrow As Integer
intStartrow = ActiveSheet.Range("First").Row + 1
intLastrow = ActiveSheet.Range("Last").Row - 1

So it is only possible to add/delete rows if the markerer is in between the above rows.

Now I would like to select the rows, from first to last. Since the rows are never the same, users add and delete rows all the time, I can not use

Range("A17:Z49").Select

Can I somehow make a range selection using the Integers, somethimg like

With ActiveSheet
Selection."intStartrow:intLastrow"
End With

View 3 Replies View Related

Using Find In Macro To Select Range Of A Table

Jan 13, 2010

I am trying to find a table of text, and copy it to another worksheet. I want to copy it as a range, not as rows or columns. Using Find, I can get to the 1st row of the table. Using Find again, I can get to the last row of the table.

What I don’t know how to do next is select the range.

For example; The table is in cells A10:F20. “Start” is in cell A10, and “End” is in cell A20.

Starting from cell A1, how do I find and select the range A10:F20.?

I will be doing this twice in the same macro, as there are 2 tables. Each of the 2 tables has the same “Start” and “End” text, as described above. The 2 tables will not always be located in the same location within the original WkSht.

View 4 Replies View Related

Lookup Cell Value From Another Workbook And Count The Match?

Feb 8, 2012

Look up a cell value from another workbook and count the match

View 9 Replies View Related

Allow User To Select Range To Copy Macro Code

Apr 30, 2008

I cant seem to get to work together in the same macro but that work great seperated. I need them to be in the same macro. The first just simply copy's text from one workbook to another:

Sub Test2()
ActiveSheet. Range("a1").Copy _
Destination:=Workbooks("punchlist.xls"). Sheets("Sheet1").Cells(Rows.Count,1).End(xlup).Offset(1,0)
End Sub

That worked ok but I needed to change it to the "active cell" instead of cell "a1". So then this line of code was made:

Dim userInputCell As Range

On Error Resume Next
Set userInputCell = Application.InputBox("Use the mouse to select a cell on any sheet", type:=8)
On Error Goto 0
If userInputCell Is Nothing Then
MsgBox "Cancel pressed"
Else
Msgbox "You selected " & userInputCell.Address(,,,True)
End If

The second code works just the way I want it but it doesnt copy over the text to the other workbook. I assume the 2 codes need to be together but I cant get it to work without errors. I also need the text to copy over without changing the borders on either workbook.

View 3 Replies View Related

Find, Match And Sort Macro

Jul 8, 2008

On my worksheet I have the 6 columns below starting in A1.

The Code is an ASX code and the PE is the price earnings for each code for the past 3 years

The 3 code columns A1, C1, E1 are letters and the 3 PE columns B1, D1, F1 are numbers.

I need to match and sort these so the codes with their PE's all match so I can compare them.

Using the codes in A1 to match the rest would be ideal as this is he most recent data.

Every year new stocks are added and some deleted so none of the rows match.

Its hard to post and example so if you need more info please ask.

I have very basic vb skills and may be able to adapt some code already posted if anyone knows of some.

Code08 PE 08 Code07 PE 07 Code06 PE 06

AAC 3.4 AAC 5.5 AAC 12
AAF 6 AAE 13 AAI 3

View 9 Replies View Related

Index And Match Functions In Macro Code

May 26, 2008

I want to write the following function using VBA. =index(B2:D8, match(lookup_value, A2:A8, 0), match(lookup_value, B1:D1, 0))

View 8 Replies View Related

Looping Macro On Find Closest Match

Jun 19, 2014

I have modified some code I found in these forums that once I enter a value in a cell I can have it find the closest match to that value and scroll down the list and paste that value as an offset. The code works perfectly, but my data will often contain the same values repeated and these aren't duplicates and I need to know how to loop the code to ensure it doesn't just find the first value but also the second (if the first is already populated) Code is:

Sub findclose()
Dim rng As Range, Dn As Range, Mx As Single, oAd As String
Dim num As Range

Set num = ActiveSheet.Range("B1")

[Code] .......

---- What I need to do is insert a loop of some sort that basically says IF my offset cell has a value then to find the next closest amount and continue the macro.

So if my list was:

700
50
500
600
500

And I wanted to find 499 then my list would look like:

700
50
500 499
600
500

BUT if I wanted to match off another amount of 501 it would keep the 499 it found and then find the 501 making the completed list look like:

700
50
500 499
600
500 501

Right now the amounts are being overidden as I don't know how to loop it...

View 6 Replies View Related

Fastest Lookup Method: Use A Key To Lookup A Value (VLookup, Index/Match, DGet, And The Rest)

Mar 26, 2008

Excel offers many ways to use a key to lookup a value (VLookup, Index/Match, DGet, and the rest). What's the fastest way to perform a lookup of a small table of, say, 30 rows of key-value pairs? Theoretically, it would be most efficient to use a branch table (also known as a jump table). See the wikipedia article for branch tables: http://en.wikipedia.org/wiki/Branch_table. Does Excel/VBA have a way to create a branch table for such lookups?

View 9 Replies View Related

Code To Select Cell At End Of Data

May 24, 2007

I am trying to copy/paste the same data range from many sheets into a summary sheet.

Specifically, I'm attempting to copy (B697:G710) from 100 or so sheets into the summary sheet, one after another

I don't know much about VBA and am using the macro recorder. Unfortunately, when I attempt to paste the data from the next sheet to the summary sheet, it overwrites the info from the prior sheet. I have attempted using the down arrow and Ctrl downarrow but the recorded macro continues to select the same cell in the summary sheet into which it pastes the data.

View 9 Replies View Related

VBA Code To Select Last Cell In Row With Data

Jul 7, 2008

I have a row of formulas that reference other sheets in my workbook (i.e. Cell A4=Sheet2!A1, Cell B4=Sheet2!B1, etc). I need to have VBA find the last cell in that row with data. I tried "End(xlToRight).Column" but it goes all the way to the end because all of the cells have formulas. I need to find the last cell that is empty of data or maybe >0 would work.

View 9 Replies View Related

Find Certain Cell That Contains Today Date - Select Cell And Its Sheet

May 8, 2014

I have made the macro that does as ,soon as i open the file, select today's date but only if date is in sheet5... sheet 5 is may so it works. Doing the same job for every sheet in the file.

View 10 Replies View Related

Code To Search And Select A Cell From An Input Box

Feb 23, 2007

I have a button set to bring up an inputbox. enter serial number.

What I need to do is enter the serial number and then have the macro look through a
single column of values to match it then go to that row.

This seemed so simple I thought I could get it but alas here I sit...

I have tried to search the forum for a similar code but haven't found one that was close enough to make sense to me. I have ut together alot of individual actions, but how to get the value inputed to "search" the column and once found go to that row.

I also need to make sure it accounts for new rows being added in the future. (no set row range)

View 9 Replies View Related

How To Find A STRING In A Worksheet And Select The Cell Containing It

Mar 25, 2009

I want to know how to find certain String and select the cell it on finding the String.

View 10 Replies View Related

Find Next Empty Row And Select Cell In Column A

Jun 20, 2006

how i can go about finding the next empty row (and select the first cell of that row (column A))? edit: It probably should be noted that there are cells in Columns A through P. There are rows where all and/or just one cell contains data per row. So i cannot use a " lookup" based on a single column.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved