Check if value in Sheet A is in Sheet B, return true, or false to respective row - vba

I'm working with two Excel sheets of over 500k rows, basically I need to validate if value from Sheet A (Column A) is in Sheet B (Column B), if so, return "True" to Sheet A (Column C) in it's corresponding row or "False" if not found.
Initially I tried the validation with vlookup (also tried match) in a separate sheet, but since sometimes I hide rows (filtered list) I encounter problems when trying to paste back the results to the original sheet because it won't paste to visible only cells although I've tried countless times. (Yes I've seen the tutorials on how to paste to visible cells only but it won't work, maybe Excel version?) Excel version is 2010.
Also things get a bit iffy when working with so much data!
How can this be accomplished in VBA?
Update: I tried what Jeeped suggested Is there a faster CountIF and it looks like what I need, I was able to actually paste the formula into all the rows without Excel crashing. Thank you Jeeped! I'd still like to know how to accomplish this with VBA to perhaps expand it later with more customization.

Related

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.

Find and correct all inconsistent column formulas with VBA

I have an excel workbook with 5 worksheets in each of this worksheets there is a table with values.
I then delete some of the rows (using VBA) depending on user selection (using dropdown list).
After my VBA code deleted all the unnecessary rows Excel states that I have "inconsistent column formulas" which I'd like to resolve with VBA before the user sees it.
Is there any way to do this with VBA?
I've searched Google the whole day now and still found nothing usefull and the only thing I'd have in my mind would be iterating through all Rows and Columns with formulas in it, checking, if the formula contains an error, which would definitely be super slow...
Note: If this counts as duplicate of Find inconsistent formulas in Excel through VBA I'm sorry, but the only answer there doesn't work with tables as data range
If you are trying to reset a formula in a Table, you can use the DataBodyRange.Formula property to reset the formula for the entire column. This addresses one way to get the Inconsistent Calculated Column Formula.
Example of the error was obtained by setting the formula for the column, changing one cell, and then telling Excel not to change the formula column after that edit.
To revert this back to a column formula (and remove the error), you can run VBA that changes the formula for the DataBodyRange.
Code to change back
Sub ResetTableColumnFormula()
Dim listObj As ListObject
For Each listObj In ActiveSheet.ListObjects
listObj.ListColumns("b").DataBodyRange.Formula = "=[#a]"
Next
End Sub
Note that I am being a bit lazy by iterating through all ListObjects instead of using the name of the table to get a reference. This works since there is only a single Table on the Worksheet.
Formulas after that code runs:
Note that this answer is very similar to the answer here.

Excel: How to compare sheets from 2 different workbooks for differences

I have an original excel file that I have ran a simulation that inputs financial data. I made a copy of this file, and wired the formulas up differently to try and increase calculation performances.
I now have 2 workbooks, the original and the final. I want to compare each sheet from each of the workbooks together to make sure that the financial numbers have remained the same, to make sure the new formulas are not effecting the numbers received.
I have tried to put copies of the two sheets into one workbook, name them April12 and April15. Then insert a third sheet. In cell A1 of the third sheet, I wanted to use the formula
=April12!A1=April15!A1
to get TRUE/FALSE values. But the formulas in these sheets reference many other sheets that are not in this new workbook, so all of my numbers turn up as #REF.
Iv googled many different ways of approaching this but I cant seem to get any of them to work. Does anyone know a simple way I can compare just the values from 2 sheets from 2 different workbooks to find out if the numbers have remained the same or have changed?
Note:I am using excel 2010.
I think you already know how to verify data using formula so is the problem to refer to a row in a different workbook ? if so, following might be helpful :
=[yourFile.xls]SheetName!$Col$Row
this way you can update your formula like(yourFile.xls refers to the complete path including the file name) :
=[file1.xls]April12!A1=[file2.xls]April15!A1

Changing Formula sheet reference with Macro

Hello everyone i'm new to this site! i wanted to see if anyone could assist with a concept i believe is possible but don't know how to achieve it.
Essentially i have a formula that has Vlookups and references other sheets, this formula is the same but the sheet referenced changes for each column as each column references a different sheet. this is going to be done 135 times over 8 times.
=IF((IFERROR(VLOOKUP(D3,'[2015_Big_Book_Communication_10_19_15.xlsx]**Credit P-1**'!$C$2:$O$5000,9,FALSE),"Not Scheduled"))=0,1,IFERROR(VLOOKUP(D3,'[2015_Big_Book_Communication_10_19_15.xlsx]**Credit P-1**'!$C$2:$O$5000,9,FALSE),"Not Scheduled"))
I want to use a macro to change the bolded sheet reference based upon a cell.
my idea is to have all the sheet names listed in a column and have the macro edit the equation for each row and then just paste the formulas transposed.
Is this possible?
Use the following formula:
=IF((IFERROR(VLOOKUP(D3,INDIRECT("'[2015_Big_Book_Communication_10_19_15.xlsx]"&H3&"'!$C$2:$O$5000"),9,FALSE),"Not Scheduled"))=0,1,IFERROR(VLOOKUP(D3,INDIRECT("'[2015_Big_Book_Communication_10_19_15.xlsx]"&H3&"'!$C$2:$O$5000"),9,FALSE),"Not Scheduled"))
In a column ("col H" in this example) write the sheet names and use indirect formula to refer to those names.

Delete Entire Rows That Have Multiple Matching Cells

I created a macro that will copy over some information from one sheet in my workbook to another to match some criteria so I may import the info into a program. Only problem is after the macro runs, there are some blank rows and a couple duplicates. I have 12 columns of info but I would like to have the macro look at and compare entries in columns D,E,F,G and L with the row above them. So D2,E2,F2,G2 and L2 would be compared to D1,E1,F1,G1 and L1. IF all five of the entries in these cells match that of the previous row, then delete the entire row.
I've found some codes that match one cell or looks for duplicates in a certain column but nothing to look and match multiple columns and I'm so new to this that I'm having trouble even getting started.
Any and all input is welcome.
You're going to have to put in the logic of your program yourself but use something like:
worksheets("Sheet1").range("A1").offset(i, 0).resize(1, colnum).delete Shift:=xlUp
An easy way to find the commands you need is to record a macro and see what Excel uses to build that macro.