VBA To Find Variable Data Or VLOOKUP

Jan 6, 2007

I have a large amount of data Range A1:DA6000 on Sheet2 in the following format:

120200 1885 | 42.43 | 130112 1992 | 49.65

120200 1886 | 45.95 | 130112 1993 | 48.08

120200 1887 | 47.65 | 130112 1994 | 49.77

120200 1888 | 45.97 |

120200 1889 | 48.34 | 130133 1887 | x

120200 1890 | 49.42 | 130133 1888 | 41.6

120200 1891 | 48.85 | 130133 1889 | 45.45[/list]

Cell A1 Sheet1 will be variable and I need to find the same value on Sheet2 in all that data and copy the number in the cell to the right to the clipboard. For example:

If Sheet1 A1 = 120200 1885 I want to find 120200 1885 on Sheet2 and copy 42.43 to the clipboard

Or if it's 130133 1887 I want "x" copied to the clipboard and so on.

I think I want to have a macro "Find" the cell and copy the one next to it, but I don't know the syntax to do that. The macro recorder only takes me part way.

I can't figure out how to make a VLOOKUP formula work, as there's way more than 65,000 lines to make a lookup table out of the data.

View 9 Replies


ADVERTISEMENT

Find And Find Again - Object Variable Or With Block Variable Not Set

Jun 5, 2007

After doing a search, I need to ask an Excel 2003 question. I'm creating a tool to open three sparate workbooks. One is the driver and I need to use it to pull data from the second and then to place that data along with additional data into the third.

My driver data may consist of a single value or multiple values separated by semi-colons in a cell. A single value works fine. The first value in a multi-value condition works fine. the second find, however, gives me an object error. I'm using the " split" verb to separate the values. Here's my code. Have you any idea why the second find is throwing up this error when the first find works correctly?

varData = Split(strRef, ";", -1)
For J = 0 To UBound(varData)

varSrchVlu = Trim(varData(J))
' do the ARIS Exrtact matching
Workbooks(strManualFile).Activate
Workbooks(strARISExtract).Activate ' Activate ARIS Extract
Sheets("Processes").Cells(2, 1).Activate
Workbooks(strARISExtract).Sheets("Processes").Range("A2").Select
Workbooks(strARISExtract).Sheets("Processes").Columns("A:A").Select

View 3 Replies View Related

Vlookup To Find Data From All Worksheets

Oct 28, 2008

I have a workbook with 32 worksheets. Data on 31 of these sheets all filter through to the one "Summary" sheet. The data on all the other worksheets is input manually and the lay-out is identical on each sheet. What I want to do is a Vlookup on the summary sheet for every sheet in the workbook, but without typing VLOOKUP(A1,Sheet1A:C,3,0)+VLOOKUP(A1,Sheet2A:C,3,0) etc etc (my sheets aren't actually called Sheet 1/2/3 etc, they have specific names).

View 4 Replies View Related

Vlookup: Find Data From Sheet 2 In Row B

Apr 19, 2009

on sheet 1 in cell C39 i need to find data from sheet 2 in row B that is 534 as in C32 is 11.2 and on sheet 2, 11.2 equals 534

View 2 Replies View Related

VLOOKUP To Find Data In Another Workbook

Mar 18, 2008

The table to the right is actually in another workbook, both workbooks will be linked. What I'm trying to achieve is a vlookup formula that will count the items in the left table that have numbers entered into them. (This table will be located within a different workbook).

View 9 Replies View Related

Vlookup And Row To Find / Copy / Paste Data?

Feb 22, 2007

I am needing to find a specific row of data in one workbook and, once found, copy and paste the values into another workbook. The worksheets in both workbooks are formatted exactly the same. Only the first eight fields of the row need to be copied (e.g. A7:H7, A150:H150, etc.)

Will a combination of VLOOKUP and ROW do this and how do I get them to work together? Once the correct row is found, how are the fields selected, copied and pasted into the specific worksheet of the other workbook?

View 6 Replies View Related

VLOOKUP With MATCH To Find Data In A Table

Jan 7, 2010

I'm using VLOOKUP with MATCH to find data in a table. I now have to add a third condition to the look up. I've attahced a file as an example. I'm not sure how to list the data for the third condtion. I created another table with the data for third condition.

View 2 Replies View Related

Vlookup & Row To Find/copy/paste Data

Feb 22, 2007

I am needing to find a specific row of data in one workbook and, once found, copy and paste the values into another workbook. The worksheets in both workbooks are formatted exactly the same. Only the first eight fields of the row need to be copied (e.g. A7:H7, A150:H150, etc.)

Will a combination of VLOOKUP and ROW do this and how do I get them to work together? Once the correct row is found, how are the fields selected, copied and pasted into the specific worksheet of the other workbook?

View 4 Replies View Related

Find Method Code: Object Variable Or With Block Variable Not Set

Sep 8, 2006

I need my program to:
- find the cell containing the string "Datum/Tid"
- record the column and the row of the found cell in two variables lCol and lRow

Here is my

Sub test()

Dim rFoundCell As Range
Dim lRow As Long
Dim lCol As Long

'Find method of VBA
Set rFoundCell = Range("A1")
Set rFoundCell = Worksheets("Sheet1").Range("A1:Z50").Find(What:="Datum/Tid", After:=rFoundCell, _
LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)

'for anyof the two lines down I get the message "object variable OR block variable not set"

lRow = rFoundCell.Row
lCol = rFoundCell.Column

End Sub

View 5 Replies View Related

Find Dates Macro: Object Variable With Block Variable Not Set

Nov 21, 2006

I found this nice little bit of code for a date range search in column A but it will not work. Apparently i have not set a variable or something.


Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Dim startDate As String
Dim stopDate As String
Dim startRow As Integer
Dim stopRow As Integer
startDate = InputBox("Enter the Start Date: (dd/mm/yyyy)")
If startDate = "" Then End
stopDate = InputBox("Enter the Stop Date: (dd/mm/yyyy)")
If stopDate = "" Then End
startDate = Format(startDate, "dd/mm/yyyy")
stopDate = Format(stopDate, "dd/mm/yyyy")
startRow = Worksheets("sheet1").Columns("A").Find(startDate, _
LookIn:=xlValues, lookat:=xlWhole).Row
stopRow = Worksheets("sheet1").Columns("A").Find(stopDate, _
LookIn:=xlValues, lookat:=xlWhole).Row
Worksheets("Sheet1").Range("A" & startRow & ":A" & stopRow).Select

End Sub

View 9 Replies View Related

Find Out What Row Or Cell Address That The VLOOKUP Found The Data

Dec 18, 2008

When I use VLOOKUP formula within a VBA routine ex:
For LoopCounter = 1 to LastRow
With Worksheets("0MATERIAL")
.Cells(RowCounter, 5).FormulaR1C1 = "VLOOKUP(RC[-2],'0MAT_UNIT'!R1C1:R65520C12,4,FALSE)"
End With
RowCounter = RowCounter + 1
Next LoopCounter

How can I find out what row or cell address that the VLOOKUP found the data? The above code works perfectly but the problem is I need data from that same row in columns 4-11. I replicated the .Cells line above and made each one a VLOOKUP (for column 4, 5, 6, etc...) but this kills the performance. I have around 32,000 rows in sheet 0MATERIAL and around 50,000 rows within sheet 0MAT_UNIT

View 9 Replies View Related

Find Method: Object Variable Or With Block Variable Not Set

Aug 28, 2006

I have a spreadsheet form with all kind of values and what I want to do is to find a data in a worksheet named "Config" based on the spreadsheet activecell value. With the find row adress I return data of another column but same row (in the worksheet) in two diferent label captions. If the spreadsheet activecell value it was found in the worksheet everything is ok but if the value is not found I'm getting the message "Object variable or with block variable not set"....

View 7 Replies View Related

Formula To Find Data And Return Other Column Value (similar To VLookup)

Jul 7, 2014

Sheet 1
Sheet 2
UPC
Sku

[Code].....

I would like to find the value from Sheet2 Column1 in sheet1 Column1 and return value from Sheet1 Column2 and Column3 into Sheet2 Column2 and Column3

And if it doesn't find anything just return Not Found

The problem that a Vlookup is not working for me is because I want it to be the exact text from sheet2 column1 but in sheet1 column 1 it should not be exact as it might have some extra text as seen in the illustration above

View 3 Replies View Related

Hyperlinks And VLookup: VLookup To Find EMail And Web Addresses

Oct 5, 2009

I have a sheet using VLookup to find EMail and Web addresses. I can get the address to show up but not as an active URL address. Is it possible to have the address "active" so I can click on it and activate the EMail or Web Site?

View 5 Replies View Related

Vlookup With Variable Name

Dec 29, 2009

I'm trying to do a vlookup inside of a FOR Loop where the lookup value is the name of a sheet, which I've made into a variable. When the next count of the FOR Loop changes, so does the sheet name. The formula gives me an error as the lookup value requires the sheet name to be in quotations in order for it to return a value. I've tried every possible combination without any success. Below, I've inserted the code

View 3 Replies View Related

Set Variable Within VLookup

Jun 24, 2013

Trying to set a current region within a vlookup. Never done this before. Data in "test 1" sheet is somewhat dynamic: rows are variable; columns are set to 12 (A:L). Thought CurrentRegion would do the trick. And maybe it still could but referencing it into my vlookup errors out. is my syntax for the vlookup incorrect.

Set test_data = Sheets("test1").Range("A1").CurrentRegion
Sheets("Test2").Range("T2").Formula = "=VLOOKUP($F2,test_data,4,false)"

View 4 Replies View Related

Name Of Sheet As Variable In VLOOKUP

Apr 29, 2014

I am currently trying to use a variable instead of an absolute name for sheets name in VLOOKUP, but it wont work:

Original formula:
=VLOOKUP($D6,ABG!$B$9:$O$12,3,FALSE)

What I would like:
=VLOOKUP($D6,$A$6!$B$9:$O$12,3,FALSE)
with A6 = ABG

View 3 Replies View Related

Variable Array In VLookup

Jul 25, 2014

Basically have a spreadsheet to track an athletic competition going of for the purposes of a fantasy game (like fantasy football). The scores from each event are being copied and pasted into a data pages and then other pages pull from that for calculations. I'm using rankings (rank.eq equation) on a calculation tab, and then using those rankings on a leader-board tab find placement via the VLookup function. The issue I'm running into is ties, when two people are ranked the same. I've been playing with this:

=IF(ISERR(VLOOKUP($J17,Men!$A$1:$G$43,7,FALSE)),VLOOKUP($J17,Men!$A$1:$G$43,7,FALSE),
VLOOKUP($J16,INDIRECT("Men!A" & LOOKUP(J16,Men!A1:A43)+1):$G$43,7,FALSE))

Where it checks for an error in the Vlookup, if its not an error then it does the VLookup, if it is then if looks up the previous ranking and the VLookup array uses Lookup to find the position of the last rank, increments it by one and starts the new Vlookup there.

View 10 Replies View Related

Add Variable Into VBA For A Vlookup Formula

Apr 7, 2014

Adjust this piece of code:

[Code]....

The lookup is for 00.2014, but this is to fixed. Want to use the same code next year to. So I already defined the variable 'jaar' which the user can choose with a validation. (and next year they set it to 2015).

I thought this code would do it but no luck:

[Code] ....

So what would be the correct way? Been shifting with the " " but its only make more and more mess.

View 2 Replies View Related

Using Variable Filename In VLOOKUP

Mar 26, 2014

I'm working on a project where I need to populate a column with vlookups taken from different workbooks, I have for the most part got it working. However currently, everytime it populates a cell it prompts the user to select the sheet from the workbook as there are two. The sheet name is always the same so I tried to add it into the code so it would avoid having to repeatedly click okay while it populated the table.

This is the original code where it asks for the user to select the sheet every time.

[Code].....

This is what is produced when it is run and the user selects the worksheet each time (which works perfectly fine):

[Code] ...........

I tried to enter the Full Costs sheet name into the code like so:

[Code] ......

However this produces the following:

[Code] .....

The issue I have found is that the square brackets that are around the filename are generated automatically, they aren’t in the actual filename and I haven’t put them in, so I am struggling to work out how to add the sheet name in where it wont be included within the square brackets, as that is what's breaking the lookup.

View 3 Replies View Related

Vlookup Concatenated Value As A Variable

May 13, 2009

Effectively I need to concatenate two columns in Sheet1, and then vlookup each concatenated value from Sheet1 in another concatenated column in Sheet2 and return the value from the next column

Now that is quite straight forward, but I am new to coding, and I was wondering if there was a way of doing it that doesn't involve having the concatenated values written to a column as a formula. Ideally what I would like it to do is put the concatenated value of Sheet1 together as a variable (I think thats what you call them) and then look up that variable in Sheet2 without Sheet2 creating a concatenated column too.

I'm of the understanding that this might be slower than writing the columns, but there is a reason for my madness.

Let me know what you think, or if i'm barking. Any suggested reading would also be handy, I don't like to bug you guys for the full code straight out.

View 10 Replies View Related

Sum / VLookup And Variable Column

Aug 13, 2012

I have a huge list of data where in column A there are customers names. Column B i can see products they are renting and column C-Z are uinits that they are renting on a given date. (lets say c is August 1st, D is August 2nd and so on). What I want is that if i a new tab in A1 enter a given date and A2 a given model, I want in A3 a formula which would provide me with Totals of that product on specified date by all customers.

Customer name
Product
Aug 1
Aug 2
Aug 3

A
Ice
2
6
4

[Code] .......

So lets say If I ente August 2 and as product Blow, I would like to know how many products of Blow are rented on that day. In this case 3 .......

View 3 Replies View Related

Vlookup Variable Range

Nov 16, 2007

I am trying to do a vlookup that currently looks as follows:

Range("C2").Formula = "=VLOOKUP(A2,SAP!A$2:AA$42,2,FALSE)"
However, the selection of the table_array (SAP!A$2:AA$42) is a set value. Instead I would like to select all the data that is on sheet SAP. The idea is that the data set will not always be A2:AA42, so I need to make this part variable.

Normally I would use

Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
to select the entire data set.

View 9 Replies View Related

Variable Vlookup Ranges

May 8, 2008

I have an Excel File with 2 worksheets.

Sheet1 contains column A as "Product Number", Column B as "Product Family". Rows contain about 20,000 lines of data. A Range has been created to cover both columns, and named "ProdRange"

Sheet2 contains Column A (blank), Column B with "Product Number"

What I am trying to do is start at the top of Sheet 2 "Product Number" (B2 is first cell ref), and use this value to do a Vlookup on Sheet 1, to extract the "Product Family" code on the Offset 1 - and insert it back into Sheet 2 Column A.

I have this below :

For i = 2 To LastRow
Range("A" & i).Value = "=VLookup("B" & i, ProdRange, 2)"
Next i

BUT for some reason it doesn't like the [ "B" & i ] part of the equation.

View 9 Replies View Related

Using A Variable In A Vlookup Macro

Feb 25, 2005

I write quite a few macros that require a vlookup formula. The table array is often dynamic which means I must change my program. I am trying to find a way to create the formula to accomodate the growth of the table array. I can count the number of rows in the table by the counta function, but then when I try to use that variable in the formula it bombs.

View 7 Replies View Related

Variable Sheet Name In Vlookup

May 23, 2007

Im have a vlookup which is specifying a table array from another tab on my workbook i.e. =VLOOKUP(J21,'Norwich CR'!$B:$AZ,6,FALSE)

I have another lookup which is feeding back the names of each worksheet (in this example its "Norwich CR". The range will be the same always $B:$AZ but i want the formula above to vary depending on whether my other look up feeds back "Norwich CR" or "Ipswich CR". how i can get =VLOOKUP(J21,'Ipswich CR'!$B:$AZ,6,FALSE) instead just by reading from another column of lookup data????

View 2 Replies View Related

Vlookup On Different Workbook With Variable Sheet Name?

May 28, 2014

I just started venturing into VBA. I'm trying to pull the data from a different workbook that will have the previous month as the sheet's name. I can't get the dynamic part of the code.

[Code] .....

View 5 Replies View Related

How To Setup Variable Range Name In VLOOKUP

Jan 27, 2012

I need to lookup a value in one of 20 lookup tables. Each table has a range name that is stored in a cell. In the formula below, U79 contains the number I want to lookup and cell P79 has the variable range name. Both formulas give me an N/A error. When I enter the actual range name in the formula, it works. how to use a variable range name?

=INDIRECT(VLOOKUP(U79,P79,2,FALSE))

=VLOOKUP(U79,P79,2,FALSE)

View 3 Replies View Related

Inserting VLookup With Variable Source Name With VBA?

Feb 23, 2012

I'm trying to create a macro that will open automatically generated report outputs and manipulate the data.

The macro will run from it's own workbook (Report Macro.xls), sheets / cells within this workbook are available as 'helpers'.

So far what I have working ok is;

Via a browse dialogs in a userform in Report Macro.xls I select 5 different report outputs. I'm storing the full filename & path in Sheet Data, Cells B1:B6 (B1 being the filename & path to the macro file). In column C I have just the filename

The first file is opened and manipulated as required. The next thing I need to do with it is to open the second file (filename / path in B3) and put a Vlookup in cell 02 of the first file which will look for data in the second (the second file will only ever have a single sheet).

As a formula I'd be using

Code:
=VLOOKUP(A2,'Email 22FEB12.XLS'!$B$7:$C$13120,2,FALSE)
In VBA if I use;

Code:
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-14],'Email 22FEB12.XLS'!R7C2:R13120C3,2,FALSE)"
It works great. However, the second filename will change and I need to take it from the macro file, sheet 'Data', cell 'C3'.

How can I use the contents of sheet Data, cell C3 in the VBA code above instead of the filename being hard-coded?

View 1 Replies View Related

Referencing Variable Workbook Tab In VLookup?

Nov 29, 2012

I have a challenge with Vlookups!

I have one workbook called Ratecards, which contains various tabs which are named based on a client code. e.g. ABC02

I then have another workbook which has employees in column B and the client code in C3.

The current Vlookup is =VLOOKUP(B8,'[ratecards.xlsx]ABC02'!$A$5:$N$168,4,false) which works fine for one client.

I want to substitute the ABC02 in the vlookup for cell ref C3, as the contents of C3 is variable and I want it to tell the sheet which ratecard to refer to.

View 3 Replies View Related







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