VBA - IF Functions And VLookups Assistance
Aug 4, 2009
The will eventually end in a series of pivottables. I am currently at the step where I need to add vlookups. This is for an inventory management report that averages 20,000 rows and 20 columns of data. I add a few columns (using vlookups) to increase visibilty to the operations dept.
The first thing I need help with is creating the VBA language for using a vlookup table from another workbook that pastes the vlookup formula every cell to the bottom of the data
Then I need to utilize an IF formula for one column that says IF c2 is blank use vlookup-formula1, and IF it is not blank use vlookup-formula2, and then paste at every cell all the way down.
I hope someone can help, and I hope I didn't write too much to where everyone will skip pver this thread.
I am currently to this state, and ready to continue.
--------------------------------------------------
Sub OHRTODDI1()
'
' OHR1 Macro
' Macro recorded 7/22/2009 by iahopbxm
'
' Keyboard Shortcut: Ctrl+o
'
' Sort and Add column Headers
Cells.Select
Selection.ColumnWidth = 9.43...........
View 9 Replies
ADVERTISEMENT
May 1, 2006
the scenario is a spreadsheet for adding call centre operators evaluations (1 being worst and 5 being best) from the clients. in the spreadsheet, i need to create a function to add a quick evaluation based on the operators score from the client
so if the score is 4 or higher it would read "good - improving"
and if it is less than 4 "poor - improving"
i think this is just a simple IF question...but i have forgotten how to do it
View 3 Replies
View Related
Oct 13, 2009
i was looking for some assistance in regards to a formula i have used for ranking. i have attached a sample spreadsheet of what i have done so far but struggling to work something so thot id try here.
(Sample WB) Currently i have managed to rank in accordance to column E but as i have alot of 0% i would like to be able to rank the 0% in accordance to the number of work done (column C).
For example i have 62 0% answers and Username Q has actioned 316 jobs with 0 Failures so should be ranked 1st as he has the highest number of jobs.
View 12 Replies
View Related
Dec 3, 2006
Is it possible if 0 cells are filled with the word “out” in a column D7 thru D15 In work sheet team matches. To run a macro that will look up a column in another sheet A2 to A10 in work sheet Random Picks. And fill column D7 to D15 In sheet team matches with the contents of them cells.
If 1 cell is filled with the word “out” in a column D7 thru D15 In work sheet team matches. To run a macro that will look up a column in another sheet B2 to B9 in work sheet Random Picks. And fill column D7 to D14 In sheet team matches with the contents of them cells.
If 2 cells are filled with the word “out” in a column D7 thru D15 In work sheet team matches. To run a macro that will look up a column in another sheet C2 to C8 in work sheet Random Picks. And fill column D7 to D13 In sheet team matches with the contents of them cells.
If 3 cells are filled with the word “out” in a column D7 thru D15 In work sheet team matches. To run a macro that will look up a column in another sheet D2 to D7 in work sheet Random Picks. And fill column D7 to D12 In sheet team matches with the contents of them cells.
If 4 cells are filled with the word “out” in a column D7 thru D15 In work sheet team matches. To run a macro that will look up a column in another sheet E2 to E6 in work sheet Random Picks. And fill column D7 to D11 In sheet team matches with the contents of them cells.
If 5 cells are filled with the word “out” in a column D7 thru D15 In work sheet team matches. To run a macro that will look up a column in another sheet F2 to F5 in work sheet Random Picks. And fill column D7 to D10 In sheet team matches with the contents of them cells.
If 6 cells are filled with the word “out” in a column D7 thru D15 In work sheet team matches. To run a macro that will look up a column in another sheet G2 to G4 in work sheet Random Picks. And fill column D7 to D10 In sheet team matches with the contents of them cells.
View 9 Replies
View Related
Apr 12, 2007
I only grasp the basics of loops and not any experience w/ formulas in VBA to date.
For each item in col "I" run this formula (the cell references are relative)
=RIGHT(I6,LEN(I6)-FIND(" ",I6))
I am only at this point so far:
Sub ItemName()
Dim wb As Workbook
Dim ws As Worksheet
Dim i As Integer
Dim LRow As Long
Set ws = Workbooks("TGSItemRecordCreatorMaster.xls").Worksheets("Record Creator")
LRow = ws.Cells(Rows.Count, 9).End(xlUp).Row
For i = 6 To LRow
=RIGHT(I6,LEN(I6)-FIND(" ",I6))
End Sub
The basic function of the loop is to Delete the first term of each cell in the range including the first space.
example:
Enjoi Barletta Deck
Resulting in:
Barletta Deck
View 9 Replies
View Related
Jun 15, 2007
I get a "#value" error message when I utilize the formula noted below. I seperated it into distinct sections so that it is easier to view. Basically, what the formula is doing is determining whether if two values are the same, then take the absolute difference of the average of other values ,excluding one of the previously noted values, and compare that difference to a different parameter. If the difference does not exceed the parameter, then calculate the difference; otherwise the ending result is zero. Pls. note that the error seems to occur when I input the fifth section into the formula.
=IF(K23="","",IF(AND(K23=E23,ABS(B23-AVERAGE(F23:J23))>B20),B23-ABS(AVERAGE(F23:J23)-B20),
IF(AND(K23=F23,ABS(B23-AVERAGE(E23,G23,H23,I23,J23))>B20),B23-ABS(AVERAGE(E23,G23,H23,I23,J23)-B20),
IF(AND(K23=G23,ABS(B23-AVERAGE(E23,F23,H23,I23,J23))>B20),B23-ABS(AVERAGE(E23,F23,H23,I23,J23)-B20),
IF(AND(K23=H23,ABS(B23-AVERAGE(E23,F23,G23,I23,J23))>B20),B23-ABS(AVERAGE(E23,F23,G23,I23,J23)-B20),
IF(AND(K23=I23,ABS(B23-AVERAGE(E23,F23,G23,H23,J23))>B20),B23-ABS(AVERAGE(E23,F23,G23,H23,J23)-B20),
IF(AND(K23=J23,ABS(B23-AVERAGE(E23:I23))>B20),B23-ABS(AVERAGE(E23:I23)-B20),0))))))))
View 9 Replies
View Related
Jun 19, 2008
I am trying to use excel to forecast budget expenditure for the fiscal year, using actuals from months past + unknown (future months).
I have this formula in cell G2: =IF((worksheet A!G70>0),F2,IF((B2
>D2),(B2-C2)*F6+F2,IF((B2
View 9 Replies
View Related
Aug 4, 2009
Current Formula
{=IF(AND(G144>0,F144:F173
View 9 Replies
View Related
Jun 13, 2006
Im doing a year nine maths project and need a little help with excel. This is my first time using macros/VBA. I have been playing around and have figured out a few things. I was asked to produce a game using excel, i am doing a kind of "racing" game with betting, i have the racing and most of the betting all working fine. I need to know how to get a message box to appear when the total of a cell reaches 0.
View 5 Replies
View Related
Dec 8, 2008
I was wondering if someone could help me generate a Macro to do the following:
I have a sheet with the following characteristics.
Column A, rows 8-15 contain headers
Column A, rows 17-24 contain headers
Column A, rows 26-40 contain headers
Column B to CV, row 6 may or may not contain an "X"
Column B to CV, rows 8-15 & 17-24 & 26-40 may or may not contain the various data
I need a macro which does the following on the press of a button located somewhere on the sheet:
Generate a .TXT file in the folder C:Test with the name "Test_YYYY_MM_DD_HH_MM_SS_Full.txt" which uses the system time and date to fill in the values In the TXT file the following data should be created: ....
View 7 Replies
View Related
Apr 3, 2007
i try to lock cells in the area the VBA code affects. My goal is to actually have affected cells by this VBA code lock immediately after anything is entered in the affected cells. Area needing Debugging is in the If - Else portion. My worksheet will be protected.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim LLoop As Integer
Dim LTargetRange1 As String
Dim LDestRange1 As String
LLoop = 10
While LLoop <= 1000
'Link column B to A
LTargetRange1 = "B" & CStr(LLoop)
LDestRange1 = "A" & CStr(LLoop)
If Not Intersect(Range(LTargetRange1), Target) Is Nothing Then
If Len(Range(LTargetRange1).Value) > 0 Then
Range(LDestRange1).Value = Date
Else
Range(LDestRange1).Value = Null
End If
End If
LLoop = LLoop + 1
Wend
End Sub
View 7 Replies
View Related
Jan 7, 2010
I'm trying to do a few things actually. I am somewhat a newb at programming, although I do understand how C++ and the coding works within Excel. To me, it's like the English language...knowing all of the vocabulary and formatting it right is important. If I don't know the vocabulary, I don't know what options I have.
This tool is being used in the call center I work in. It is to help eliminate repititious information used to notate accounts. I have attached a picture of what the tool looks like so you can have a better idea of what I'm working with. Here are a list of things I'm trying to do which I have searched and not found answers to:
1. I am trying to use a middle mouse scroll to scroll through validation list. This list information is located on a different locked tab. Basically, I have a few rows where a drop down selection can be made and it would be easier to scroll rather than manually moving the slider within the validation list.
2. As you can see, this "tool" an employee and I have created has many buttons. What I would like to do is to be able to click a button on the right and have it "stack" text within a single cell. In other words, if I click the button once, the text may be entered into the "actions taken" cell. If I click another button, I can have the option (or maybe a little "+" next to the button) to add this button's information to the end of the information already entered within the "actions taken" box. I've tried recording and using the keyboard and selecting "end" and then having the text added, but it didn't work. I've seen "loop" VBA code, but I don't want something to repeat, I want it to stack in the cell when clicked manually.
I'm sure there is a way to make the tool much better using VBA code and not use Excel, but I don't have an extensive knowledge of Excel to do something like that. I'm a very fast learner and understand how the coding works, so if you have an idea which may help, and you understand what I'm trying to do here, please provide your .02.
Basically, it's used so the Customer's name and phone number are entered manually, and then just about everything else is automated by the use of the buttons on the right. If I could get the 2 above options to work, it'd be perfect. I just figured out I could eliminate screen flicker and hide the macros working by using:
View 12 Replies
View Related
Mar 26, 2008
I have an array (partArray) that contains a number of parts that I need to get values for. The part array is populated (Thanks Norie!) by bring in the contents of a cell and splitting them into array elements. I then run them through a trim loop to remove the white spaces. Up till here thefunction works fine.
I created a partRSL array to hold the matching value for each part ( I know i can use multidimensional arrays but i dont understand them yet and need to deliver a prototype to get some approval from senior mgmt ).
The idea is that as we run through each element of the partArray we will vlookup the corrseponding value and assign it to the appropriate element of the partRSL.
When I use the function below it returns a #value. I think that the element of the partArray i want to lookup is not being used as a string and so the lookup is failing.
As a test to see that this is working i have the function returning the value of element 0 in the partRSL array as it is distinct from the rest. (It should be returning a number (integer)
Function FindAlt(option_address)
' Initialise the array
Dim partArray() As String
Dim partRSL() As String
Dim i As Integer
'Populate Array by spliting the comma separated contents of the select cell and assigning each to an array element
partArray = Split(option_address, ",")
'This works fine
For i = LBound(partArray) To UBound(partArray)
partArray(i) = Trim(partArray(i))
Count = Count + 1
Next
View 9 Replies
View Related
Dec 17, 2012
I am trying to write a UDF function where I lookup if a value is on a range on different sheet. I would like to be able to write what I want the result to be in the function. I also hard coded that the function need 3 range and 3 results, but I know it is possible the make the number of component vary depending on what the user writes. I would like my function to do that.
Here is what I have written so far :
VB:
Function find_para2(var As String, rng As Range, result1 As String, rng2 As Range, result2 As String, rng3 As Range, result3 As String)
If WorksheetFunction.IsNA(WorksheetFunction.VLookup(var, rng.Address, 1, False)) = False Then
find_para = find_para & result1 & ", "
[Code] .....
View 6 Replies
View Related
Jan 31, 2013
I need returning a working hyperlink from a vlookup. I have a table with part #'s and hyperlinks. On another tab I want to type in a part number, have it search the table and return the working hyperlink. This will allow the user to just click it and go to that tab.
Here is my example spreadsheet : Book1.xlsm
View 2 Replies
View Related
Dec 17, 2008
I have a vlookup for one cell into another sheet however it retruns #n/a(cell A1) the cell adjacent is an if command (Cell B1) it reads if(b1>0,1,0) the only problem is if the cell (A1) will not return zero just #n/a how can I turn the #n/a into a zero? so cell A1 will return a zero and not #n/a
View 6 Replies
View Related
Aug 12, 2009
I have a list of cells and for each of them I preform VLOOKUP in a certain table.
Now, I want to sum the values all the VLOOKUPs without viewing the results of each VLOOKUP. In other words, I don't want a cell for each VLOOKUP result. I am only interested in their sum.
Is there a way to do this?
View 13 Replies
View Related
Feb 6, 2009
I have a simple Staff Rote which is fed by data on Time Sheet. Currently it is working ok with two definitions;
T : Time
B: Break
If I introduce a 3rd and 4th definition like;
A: Leave
X:non working day
formule will get even more complicated.
Is there a way of simpifying this with a code and introducing the new definitions.
View 11 Replies
View Related
Feb 14, 2012
I want to vlookup one value into two different tables and return the 2nd column in the respective table it finds the value in. if it does not find the value in either table, return "". Currently I have the formula below, but it is not working 100%.
=IF(E6="Shipped","Printed",IF(NOT(ISNA(VLOOKUP(C6,Master!$GP$4:$GQ$5000,2,0)=1)),"Printed",
IF(NOT(ISNA(VLOOKUP(C6,Master!$HD$4:$HE$5000,2,0)=1)),"Ready","")))
View 1 Replies
View Related
Jan 5, 2007
Any recommendations on vlookups being able to recognize a value that does exist within a table? It returns an N/A and the formatting is the same for both references.
View 9 Replies
View Related
Jul 6, 2006
I am having trouble using an if statement with a vlookup.
The first calculation i am trying to do is calculate the cost of storage for the product, each product (3 of them) has it's own charging matrix which i have turned into a table on another sheet and therefore want to use the vlookup to return the correct values (meaning that i can change the underlying table and not have to change the formula each time a price change occurs), the sheet calculates the dwell time between entering and leaving, if dwell time is less than 7 days the charge is the number of days * products <7 days rate, if it is >7days then the charge is 7 days at the products lower rate and then the balance at the higher rate. I have a formula that is a longwinded way of calculating it for one size only but would like to add vloopup so that dependent on the units size the storage is calculated.
I have attached a sheet as an example, you will see the data table is quite large and as we consume extra services i plan to use a tick box to indicate use and then add this to a running subtotal again through an if and vlookup.
View 9 Replies
View Related
Oct 28, 2009
=ROUND(SUMIF($C$26:$C$106,D126, $F$26:$F$106)/COUNTIF($C$26:$C$106, D126), 0). the formula is from a sheet which is used as like a questioning/ skills matrix.
The reference of d126 is a category eg: complaint handling and there might be 4 questions on complaint handling each of the answers being displayed as a number between the cells f26-106. If any of these individual cell results are equal to 0 or 1 then i want the overall answer for the formula to default to "training required" rather than the value it would give.
View 4 Replies
View Related
Aug 25, 2008
I am trying to write a formula that will give more than 1 return for a vlookup statement.
The info i am looking up is sku code (col a) and expiry date (col b).
There are more than one entry for some skus , but I am only getting returned the first expiry date.
View 13 Replies
View Related
Feb 2, 2009
I know how to do a vlookup and I know how to do an if statement. I also know how to do an IF(ISERROR or IF(ISNA ....
However, I can not get this to work:
=IF(C73<7,VLOOKUP(D73,'Package Mix'!$G$39:$H$45,2,FALSE),IF(C73<13,VLOOKUP(D73,'Package Mix'!$G$6:$H$36,2,FALSE),IF(C73>23,VLOOKUP(D73,'Package Mix'!$G$48:$H$56,2,FALSE),"")))
I can not wrap my head around how to make this work w/ IF(ISNA ....
Also, why must you use < or > .... I actually want the numbers to be 6,12, and 24... However, it seems when I use an equal sign it fails.
View 7 Replies
View Related
Jul 7, 2009
I am trying to create an asset management database using excel, and would like to be able to add custom notes to each entry (index) so as time goes on, I can refresh my memory what we have done with a particular item. I have attached the current file I have created.
Essentially, when I use the GREEN drop down menu in the top right, I want it to display the notes/comments that I enter in the rightmost column of the data, as the attached file illustrates.
However, I want to be able to hide that rightmost column and be able to edit the data from the new area (white space) it is being displayed in, however as I have it set up right now, if I edit the cell, it edits the forumla and poof goes all the comments and the formula becomes messed up.
View 5 Replies
View Related
Nov 3, 2011
I have a table that has the data below
Month Jan Feb Mar Apr
Brand 0 1 2 3
I want to do a vlookup with match to find the month and then return the value of a rolling 3 months.. So if i look up Apr i want to look at the rolling 3 prior months average ie, average of (Jan,feb and March). i have the vlookup formulas working, its when i include the multiple vlookups (Match -1, -2 etc, the average is calculating the blank cells for some reason..
View 1 Replies
View Related
Jul 4, 2012
I have done a V-lookup that auto populates my project report doc with different lead times/dates depending on the product selected. Problem I have it that the dates being pulled through are for all calendar dates and not just working week days.
I know you can select a selection of dates and fill as week days however all of the dates on my primary sheet either have the project start date minus lead time formula or the vlook up formula in it. Filling week days overwrites any of this.
View 3 Replies
View Related
Apr 12, 2013
I'm attempting to work with a v-lookup that will have multipe results. In column A of my spreadsheet are invoices numbers and in column B are account numbers. An invoice can have multiple accounts. For example, there are two lines for invoice "ABC", each with a different result in column B (see below)
Invoice Account
ABC Cash
ABC Receivable
My goal is to have the vlookup bring in both values, but in separate rows (see below)
Column A Column B Column C
ABC Cash Receivable
View 7 Replies
View Related
Dec 13, 2013
I'm trying to nest the following:
=IF(VLOOKUP($F6,'Dept location'!$A:$B,2,FALSE)>0,VLOOKUP($F6,'Dept location'!$A:$B,2,FALSE),FALSE)
=IF(VLOOKUP($H6,'Project location'!$C:$K,9,FALSE)>0,VLOOKUP($H6,'Project location'!$C:$K,9,FALSE),FALSE)
=IF(VLOOKUP($V6,'Dept location'!$A:$B,2,FALSE)>0,VLOOKUP($V6,'Dept location'!$A:$B,2,FALSE),FALSE)
To start with, not sure I have the ">0" part correct in the above IF statements. That expression is meant to be asking it: Is the VLOOKUP finding valid data (result #N/A)?
Next, comes the nesting part. If the VLOOKUP isn't finding valid data (result = #N/A), then I want it to move on to the next IF statement.
I have 3 different columns I want it to look at; hence, the 3 IF statements. In the end, if none of the three IF statements results in any valid data, I want it to give the result "Research".
View 2 Replies
View Related
Jul 31, 2014
I'm having issues with a formula that I am using to add three vlookups together. The problem is that there may or may not be data in one of the columns I am looking up with the vlookup. I am looking up hold times for reps each week then adding them together to get a monthly sum. This formula works when data is available for all 4 weeks. When I have a rep that started in the middle of the month there isn't data for all 4 weeks so I want Excel to just treat that as a 0 or Null, Currently it just provides a 0.0 for the whole thing instead of adding what is there.
=(IFERROR(VLOOKUP([@Name],Sheet2!A:H,2,0),0))+(IFERROR(VLOOKUP([@Name],Sheet2!A:H,4,0),0))+(IFERROR(VLOOKUP([@Name],Sheet2!A:H,6,0),0))+(IFERROR(VLOOKUP([@Name],Sheet2!A:H,8,0),0))
View 9 Replies
View Related