Check if a Cell Value exists in column, return a value in the same row but different column - vba

I have a large sheet of data in Excel that comes from a vendor daily but I only need certain things from this worksheet. I don't want to delete any of the data I don't need as its used by others and I don't want to filter the data for other reasons. I've tried some other Excel formulas I've found from other users questions and they don't quite do what I need them to do.
All of the data from the vendor comes via a text file and through connections that I didn't setup, we use the "Refresh All" button on the Data tab of the Ribbon to import the new data from the text file into Sheet1 on a daily basis.
I have created Sheet2 where I plan to use the data for manipulation. What I am trying to do Sheet2 is look for the value "A" (what we call an account tag) in Column B of Sheet1. If the value "A" is found then output the value of the cell located in Column A (the account number) of the same row that the value "A" was located on. I want it to skip all the rows that don't have an "A" in Column B as there are several other tags in Column B that are not useful to me.
I need to pretty much repeat the same process to pull the accounts balance from Column AA but once I figure out how to do the above I am sure I can use the same method to pull the balance information.
I have attempted to use VLOOKUP, MATCH and a couple other methods but I can't seem to figure out how to do this. Another thing I'm afraid of is if I get the formula right, it is going to give me blank rows on Sheet2 for all of the rows on Sheet1 that don't have the "A" value, which I don't want it to do. I only want Sheet2 to contain the information I need. I have a feeling I might need to do a Macro, but I am not sure where to start.
Thanks,
EDIT as of 05/31/2016
Ok, so I will attempt to clarify this.
Sheet 1:
Data that is Input
Sheet 2:
Data that is Output
If you look at the image of Sheet 1 Column B has what I am going to call Tags. I need excel to look in Column B for any rows that have an A tag and copy the Account number to Sheet 2 (the output sheet) and then look in Column AA and copy the Balance so that my results on a second sheet look like the image I posted in the second image(the output sheet). There is other data I'll be dealing with on sheet 2 but for the purposes of explaining my problem I only need this information.
If you look at Sheet 1 you will notice that the account number is the same for many rows until I reach a new account number which is tagged with another A in column B. So I need excel to ignore all the other rows until it sees another A in column B and repeat the process of collecting the account number and the balance.
I hope this clarified the problem.
Thanks,

One can use the Macro recorder to begin code. You need an operation to record.
If I have some data
Team Points <space> Team
Leicester 81 <space> Arsenal
Arsenal 71 <space>
Spurs 70 <space>
then I can use from the Data ribbon "Advanced" which throws a popup box, where one can select the List range, and a criteria range. Also one can choose for Action the Copy to another location.
Running this I can get
Team Points <space> Team <space> Team Points
Leicester 81 <space> Arsenal <space> Arsenal 71
Arsenal 71 <space>
Spurs 70 <space>

Related

VBA: Copy one value, paste it down the row for fixed number of times and then repeat

I am working on cleaning weather data available online on Canadian Government website. The problem sounds simple but unfortunately I couldn't get what I want via VBA.
WHY DO I HAVE A PROBLEM?
To clean data, I want to see if there is relationship between weather and moods.
The data is divided in sections (i.e one section by station for one year). Each section of the data has daily weather information (365 rows, 366 for leap year) in tabular form. The station name is nowhere mentioned in that data. It is only mentioned in one cell at top of each section. So I want to copy the station name from the header section and paste it down the row for all the days.
For-example:
If there are 8000 stations in canada that are monitoring weather data daily, then there will be 8000 sections of tables, each section will have daily weather data.
Here's my query in steps:
1) Copy one value of cell(cell B1) and paste it down the row 4694 times range(AC27:AC4720). 4694 covers 10 years +section headers, empty spaces.
2) Move down one extra row (so leave AC4721 blank)
3) Start the process again.
The function has repeat the process till the end of the file.
Formula in simple language:
continuing after blank space....
the cell is at AC4722 now, relative to this cell the formula has to copy the value of B4696, repeat step (1) and step (2) of the query.
In this way the next will AC9417, relative to this cell the formula has to copy the value of B9391, repeat step (1) and step (2) of the query.
The difference between relation positions (AC27,B1), (AC4722,B4696), (AC9417,B9391) is always 26
Please help.
To input the value all you need to do is:
Range("AC27:AC4720") = Range("B1")
No need to iterate over each row.
The hardest part is working out the range that you need to copy it to. Which can be done many ways depending on how your file looks.

CheckBox to limit a data validation list

Moving forward, slowly.......
I added a column, that with the combination of my checkboxes, gives the name of active employees.
Screen Shot of active list of employees
If I use $T$6:$T$16 as my validation list, I still get 11 options in the drop down. I want the drop down to show only the 5 names that are in that list.
No need to use VBA here, Here's a quick solution.
Use a 1 or 0 in a column next to the employees' names corresponding to whether they are active or not.
Then create a column in the sales sheet which has a vlookup for this value
=VLOOKUP(E4,$A$4:$B$8,2,FALSE)
This looks for value E4 (the name), in range of all names, second column for their active status, FALSE for an exact match.
Then use a filter:
Highlight range of sales
"Data" tab
"Filter"
Then you can use the filter on the new Active column to only show the employees which are still active. See the linked image for the final outcome. The vlookup lives in column D.
Final outcome image in Excel
Of course if you want this in two sheets, you can split what I've done to different sheets with no extra effort other than adding sheet references to the range in the vlookup.
Hope this helps

Excel - Can not compare two spreadsheets

I have gone through V-look-up guides online but I can not find one that explains what I am looking for. I am trying to avoid manual checking.
What I have:
Two sheets, Sheet 1 and Sheet 2. Both sheets have the same column names (A1:G1) with multiple rows.
Sheet 1 contains my spreadsheet where I update daily. Sheet 2 is the same spreadsheet that is imported from a application (but has hourly updates). Data can change in each row (for some columns) along with additional added/deleted rows. The data is text, dates and numbers (mixture of both too).
I want to run a formula to highlight the changes on sheet 1 (grabbing the updates from sheet 2. Once I find out the formula works correctly, I would like to know how to replace the Sheet 2 updates onto my spreadsheet (Sheet 1).
I am looking for a formula outside of creating a macro (worst case scenario).
Currently I have the following vlook up formula:
=VLOOKUP(A1,sheet2!$A:$A,1,FALSE)
When I run this in another column (lets say in H1 in Sheet 1), it will display "N/A" if that column (A1) in Sheet 2 is not the same. If it is the same, it will write out the column name.
When I use the following formula highlighting all the cells in Sheet 1, I get a values error:
=VLOOKUP(A1:G33,Sheet2!$A:$G,1,FALSE)
How could I apply that formula to the whole spreadsheet (I guess it would apply to both sheets) and have it highlight records in my spreadsheet (Sheet1). Could it also highlight rows that are missing or added?
The data in Column 1 and 2 would never change (they are ticket numbers). Only change that can apply is if ticket is closed, so when I import the updated spreadsheet that row isn't there anymore. If you think there might be a better way to tackle this down, I would like to hear.
Please let me know if I am not clear.
Here are some example screenshots:
Just in case, the formula for the totals are (adjusting the columns for each):
=SUBTOTAL(3,INDEX(C:C,2):INDEX(C:C,ROW()-1))
Sheet 2 is setup very similar. When I import it into excel, the columns are the exact same as Sheet 1, the only difference can be more/less rows (along with the updates for each row).
You can use conditional formatting.

Splitting data between worksheets depending on status of Column A

I have been asked to create a database of volunteers in Excel. The main worksheet (called Data) holds all the information – names, addresses, numbers, reference checks, placements, supervisors, etc. What I am trying to achieve is for the relevant information to be moved from one worksheet to another when the status of the person changes.
There would be 5 categories which the volunteers would fall under (column A labelled ‘Status’)
PROCESSING
ACTIVE
ON HOLD
BARRED
STOPPED/RETIRED
What I want to get is a live database so the information would appear on a relevant worksheet whenever the status on the main spreadsheet changes , but I only want some information to show depending on the category…
Each Worksheet would contain columns A-F from the ‘Data’ worksheet and in addition:
Processing would contain columns X-AE
Active: AF-AW
On Hold: AZ-BC
Barred: AX-AY
Stopped/Retired:- BD-BH
I have searched and searched again but I know nothing about Macros (and my IT department is unable to help) So my question is – is this doable and if so is anyone able to help me?
I hope I am making sense and if not I can email across the dummy database with some made up names to show what it is I am trying to create
You can do this using array formulae. This link shows a simple example which provides the basic formula (explained in detail in the linked article)
=INDEX(range,SMALL(IF(col=value,ROW(range)),ROW(1:1)),COLUMN(A2))
Where range is the range of all your data from your main worksheet and value is the value you want to screen for (this changes for each of your sheets) and col is the column on your main sheet that you want to check the values of. Note it is an array forumla so you have to press control+shift+enter after typing in the formula as explained at the bottom of the link.
You will notice that I have changed the formula to say COLUMN(A2) instead of 2. This is so that you can drag the formula across the columns as well as down the rows. You might need to make this COLUMN(A2)-x where x is an offset because your data don't start in column A.
Note that the same applies for the ROW(1:1) part, if your range doesn't start in row 1 then you will need to offset this by some value as well (i.e. something like ROW(1:1)-y)

VLOOKUP on first and last name with no unique ID

Situation:
I have two sheets: The first sheet contains a list of employee names; the second sheet contains a piece of a pay report for employees. I need to pull the employee pay data from sheet 2 to sheet 1 by searching for the employee on sheet 2. What complicates this is the report on sheet 2 contains changing employees, pay, and has no unique ID.
I am looking to fill in column A. I cannot permanently modify this sheet as it affects downstream reporting.
I split column B which was previously first name, middle initial (if any), last name. Note, about 10% of the names may have a different last name. For example, sheet 1contains the name Tara Feather, but the second report uses her maiden name of Tara Bird.
Attempts so far:
I am new to Excel, and am just learning VLOOKUP. My first attempt was to pull the data based on the last name column on sheets 1 and 2, and enter data. Unfortunately, while that worked for 90% of the entries, the last 10% had the wrong values and the audit to correct took more time than manual entry.
Possible Ideas:
My next thought was to combine an If statement and VLOOKUP so that if last name matched, and first name matched, then execute the VLOOKUP and pull values, or enter "ERROR".
With this new thought, I don't know if I'm now in macro territory or if there are a combination of functions that can help. Ideally, the more it can do with 100% accuracy the better. However, if it can highlight the names it completed on sheet 2, I can always enter the non-highlighted manually, still saving time.
What are your thoughts and direction?
You want 100% accuracy, but if someone has different names on the two sheets, then that's never going to work.
So to get 90% of it right:
On the second sheet put this formula in G2 and copy it down for as many rows as you have names.
=B2&D2
Put this formula in H2 and copy it down
=F2
On the first sheet put this formula in A2 and copy it down
=VLOOKUP(D2&C2,'second sheet'G:H,2,false)
Any rows where it can't find a matching firstname and surname will have #N/A in them.
Assuming you can modify the second sheet permanently you can put the right surnames in so that the formulae work. You could also put in the middle names into the formulae in case you have two people with the same names.