VBA To Compare Two Worksheets In Same Book
Jan 8, 2010
I have a workbook that contains two worksheets. The columns are the same between the two, column A is the Employee ID in both worksheets. The other column headings are: Name, address1, address2, city, state, zip, EmgerName, EmgerType, Cell, Address1, Address2, City, State, Zip.
What I'm looking to do is compare WS1 with WS2 and in WS2, what ever is different from WS1, the font color changes to RED. For example let say for employee number 1234, everything is the same expect for EmgerName and Cell, then these fonts are changed to RED in WS2 so I can identify them quickly.
View 8 Replies
ADVERTISEMENT
Jul 18, 2014
I made the following code to merge 2 workbooks together.
The code is to be executed when the user has Workbook A opened. (All sheets in workbook KPISWD are supposed to be moved after all worksheets in workbook KPICustomers).
I keep getting a debug error on the code that is supposed to do the actual move and loop until it is finished with all of the sheets in Workbook B.
Code:
Dim KPICustomers, KPISWD As String
KPICustomers = ActiveWorkbook.Name
Workbooks.Open Filename:= _
"W:FacturatieKPI per periode SWD.xls"
KPISWD = ActiveWorkbook.Name
[Code] ..........
View 3 Replies
View Related
Oct 7, 2007
I have a macro that I would like to run on every worksheet in my book (over 100 sheets wide). As it takes about 20 secs to run on each sheet, and I don't want to click from sheet to sheet, how can I make it run on every sheet in the book? And no, they aren't named sequentially, either alphabetically or numerically.
is there a function in Excel to return the number of sheets in a book?
View 9 Replies
View Related
Feb 24, 2014
I have one sheet for each day of the month with a table that has Employee Name, Reason, and Expected Return. I need to copy each line into the monthly sheet, but each day may have varying number of rows. Needless to say I would like to do this without copying lots of blank lines into my consolidated sheet.
View 10 Replies
View Related
Jun 22, 2007
I have the below code, which now looks to see if a file is open or not, if it is, then copy and past 'Data' and if not open the book and copy 'Data'.
I think the code is sort of right, but im missing something, as i keep getting runtime error when i try and copy. Here is the
Sub PrintSaveKPIUpdate()
Dim sFilName As String
sFilName = "C: estCashSales_KPI.xls"
Set Main = ThisWorkbook
If IsOpen(sFilName) Then
' Book is Open.
Worksheets("Setup Data"). Range("Data").Activate
View 9 Replies
View Related
Aug 29, 2007
i have done a search on this topic and found many similar answers to many similar questions. All specify using Application.Run "workbookname.xls!macroname".
In my code, the filename has an assigned value as the master code goes out to many secondary files - the user selects the particular one they want at the start of the macro. The variable assigned is called "UpdateKAMsFile".
how do i get the macro called KAMsRandomColour to run in the workbook designated by UpdateKAMsFile?
View 9 Replies
View Related
Jan 6, 2010
Hi Could someone please have a look at this please. I have a macro kindly supplied by jrdnoland that now needs a little tuning.
View 9 Replies
View Related
Jun 2, 2007
How do I compare two worksheets?
I have two worksheets with similar data. I want to compare and mark the ones that do not compare.
Then copy the changes to the main worksheet?
View 9 Replies
View Related
Jun 2, 2003
I m running compare between two worksheets.
1.1st sheet is my new data.
2.2nd sheet is my old data.
3.3rd sheet is where I want to show the differences.
Im looking to do the following:
1.Compare Column A from the old data (sheet 2) to the new data (sheet 1). If a new value for Column A appears in sheet 1 and is not on sheet 2, then I want the row copied from sheet 1 to sheet 3 and be appended by ADD in Column M.
2.Compare Column A from the new data (sheet 1) to the old data (sheet 2). If an old value for Column A appears in sheet 2 and is not on sheet 1, then I want the row copied from sheet 2 to sheet 3 and be appended by DELETE in Column M.
3.Compare Column A from the old data (sheet 2) to the new data (sheet 1). If the value for Column A is the same but the value for either Column B or Column L is different then I want the row copied from sheet 2 to sheet 3 and be appended by FROM in Column M and I want the row copied from sheet 1 to sheet 3 and be appended by TO in Column M.
View 7 Replies
View Related
May 19, 2006
Im trying to compare the 4th column in 2 sheets, the "New" sheet and the "Old" sheet.
Any differences should be recorded in a "Test" sheet.
This is the code im using:
Sub Test_Click()
Dim a As Long
Dim i As Long
Dim j As Long
Dim last_row As Long
Dim last_rowP As Long
a = 2
last_row = Sheets("Old"). Range("b65536").End(xlUp).Row
last_rowP = Sheets("New").Cells(65536, 1).End(xlUp).Row
Im using a loop that starts at the end of the "New" sheet going through each row in the "Old" sheet. Then moves onto the the second last row in the "New" sheet, etc...
When it finds a difference it enters that row into the "Test" sheet.
View 3 Replies
View Related
Jan 11, 2007
I have two worksheet, I would like to compare sheet1 column A and B to sheet2 column A and B, if A and B is the same,copy sheet2 column C.
For example: ...
View 5 Replies
View Related
Jul 16, 2014
so to start off im not able to attach things due to security reasons, what i need is either 1 of 2 macros. if its possible, both are related. one possible is as follows: i need it to go through a certain column (say I for example) and look at the information in it, this information can vary from peoples names along with dates and other stuff, i want it to look through these and if anything has a date today and prior i need the cell to be highlighted. problem is sometimes it might have 2 dates, or no dates. it should have todays date, their name, other information, and future date of something. but not everyone does, this is the macro i dont think that can exists.
2nd macro possibility the other macro uses the first sheet, AFTER been highlighted, normally by hand, and takes it to another workbook and puts in in certain spots. so the first sheet has names of everyone in column K. what i need is it to look at column I and if its highlighted take entire row to other book, and put into sheet under the person name in their tab. the second book has a tab for each person (at this time 18 tabs) which can fluxuate, and each tab is the persons first and last name, without spaces. since when i put sums on main page it didnt want to work with the spaces i had to omit them. again im not sure this is possible.
View 6 Replies
View Related
Jan 29, 2010
The data is spread across worksheets however the first column of every worksheet contains same data (eg. Name). Evenso, the rows wont correspond each other across worksheets. eg.
WS1
Name: Variable 1: Variable 2
John : X : Y
Mary : A : F
Mary : F : W
Lance : E : G
Lance : R : T
Lance : D : W
Neil : R : H
Neil : H : S
WS2
Name: Variable 1: Variable 2
John : X : Y
Mary : A : F
Lance : E : G
Lance : D : W
Neil : R : H
Neil : H : S
Neil : G : W
Is there anyway to correspond these rows and add blank rows so that if Lance is in 3 rows in WS 1 it will be the same in WS 2 as well even though some rows are blank? And vice versa?
View 11 Replies
View Related
Aug 15, 2013
I have 2 worksheets I need to compare. One of the worksheets is sent to me from a vendor and its not in the same format (regarding the order of column labels). What would be the most efficient method to compare these two spreadsheets in a way that I can call out anything that is not in BOTH spreadsheets?
For example, if John Doe shows in spreadsheet A but not in spreadsheet B, can I get that to call out? Likewise if its in B but not A? Im basically trying to locate all discrepancies between the two.
Not sure if I have to get both worksheets in the same column order or not
View 1 Replies
View Related
Dec 21, 2009
I have a master tracking document that I use to record project information. My client sends me an updated schedule each week which may (or may not) have additional stores on it and some of the details of the stores may have changed.
I need a macro to capture these changes from the source spreadsheet (the one the client sends) and update the master tracker. The master tracker has a lot of additional columns of data that I add in myself about each project so I don't want to lose this information. The macro needs to see if the store on the source sheet is already on the master tracker and if it is then it needs to check to see if any of the columns below have changed.
If the store isn't on the master tracker then it needs to be added. There are around 750 stores on the master tracker at the moment so to do it manually takes forever!
Master Spreadsheet
Column A - Retail Region
Column B - Project Name
Column C - Postcode
Column D - Net Selling Area
Column E - Project Manager
Column F - Contractor
Column I - Start On Site
Column J - Launch Date
Source Spreadsheet
Column C - Retail Region
Column D - Project Name
Column I - Postcode
Column J - Net Selling Area
Column M - Project Manager
Column N - Contractor
Column P - Start On Site
Column Q - Launch Date
View 9 Replies
View Related
Feb 13, 2009
I am trying to compare almost 2 identical spreadsheets. Please see the attachment below. This is used by our HR department to identify people that are active or inactive, department, title, who are their supervisors, etc. This spreadsheet will be updated monthly to reflect all the changes (new employees, people move from one dept/home location) to another, come back from temporary leave, promoted, or terminated). I saw some macro code application to highlight the differences of 2 spreadsheets but the spreadsheets are so much simpler than mine. We have approximately 1000 employees.
View 7 Replies
View Related
Jan 19, 2007
I am new-hire training programmer in multinational semiconductor company in Penang, Malaysia. I had been given a project to compare one data sheet (sheet 1) with another one data sheet (sheet 2) and the result is displayed in another sheet (sheet 3) in the same workbook.
1. To start compare, I need to click a button (command button) in Sheet 1 and then VB will run and displayed the result in sheet 3.
2. The comparison is based on the wafer map which is :
i)Value=1 in sort4(sheet1) is equal to the value=1 in Pattern Verification(sheet2), the result will display PP(Pass/Pass) and count the quantities of PP.
ii)Value=1 in sheet1 is equal to value other than 1 in sheet2, the result will display PF (pass/fail) and count the quantities of PF.
iii)Value is other than 1 in sheet1 is equal to value=1 in sheet2, the result will display FP (fail/pass) and count the quantities of FP.
iv)Value is other than 1 in sheet1 is equal to value other than 1 in sheet2, the result will display FF (fail/fail) and count the quantities of FF.
v)All the result will display a new wafer map with all result above. Result will display in Sheet 3........
View 8 Replies
View Related
May 31, 2007
I have two worksheets, PM1DATA and AMDATA, i'm looking for a way to compare the two sheets and have any data that appears in collumn B within the AMDATA sheet, but NOT within collumn B of the PM1DATA sheet to be copied and moved to a sheet called NEWKITS. I would like the entire row to be copied when new data is found, not just collumn B.
View 2 Replies
View Related
Jun 6, 2007
I have 2 XL sheets with the below data.
Sheet 1
EMP# Ename
111 AAA
222 BBB
333 CCC
Sheet 2
Emp# Marks
222 80
111 90
333 60
Now i want a macro which will compare the data of the two XL sheets with the help of Emp# and produce a new XL sheet which will look like this
Emp# Ename Marks
111 AAA 90
222 BBB 80
333 CCC 60
View 7 Replies
View Related
Oct 6, 2007
So far the code compares two worksheets of two different structures that have been merged into one workbook. It compares by the row ID number appearing in column B of worksheets 1 to the row ID number of column 3 worksheet 2- the aim being to concatinate with all names in worksheet 2 that have the same row id number as that of row id number in worksheet1- the concatination is output producing a list of names in column T in worksheet 1 -for what will be a later be part of a label mail list. The code mainly works great and does allow for when no matching row id found on second wroksheet as it just uses the name on the first worksheet - but the PROBLEM I am having is the code hits a bug /stops in cases when a single person on worksheet 1 also appears in worksheet 2 and there is other people on the 2nd worksheet with same row ID to concatinate with. So at this time the code hits a bug when it comes across one of these cases so what is needed is for a change in the code so in these cases then it will use for the output the name in the row of the first worksheet of the row id it was comparing.
To make this easier to understand sample test file is attached with code as below included- if you run the code it will stop but you will find output would have started to output to column T of worksheet 1 - but when it got to Sue Rubble it stopped - if you were to delete Sue Rubble from the 2nd worksheet the code would not bug. However the real data workbooks does have cases of single people who may or maynot also appear in the second worksheet - the code as well as what it can achieve so far does also need to allow for these other case as described by outputing the name appearing against the row id in the 1st worksheet.
Sub PharlapTheData()
Const TEST_COLUMN As Long = 3
Const NEW_COLUMN As Long = 4
Const NAME_COLUMN As Long = 4
Const TARGET_COLUMN As Long = 20
View 9 Replies
View Related
Dec 6, 2007
I would to ask how do I match the values in Sheet1 and Sheet2. As you can see in the attached example, I need to get first in Sheet3 if there is a certain individual in Sheet2 from Sheet1. After that, I need now to fill out the remaining columns in Sheet3 to match values for the corresponding names.
View 3 Replies
View Related
Jan 17, 2008
I would like to create a macro button that when pressed will make a comparison of the data that was inputed by the user and the raw data on another spreadsheet. If the number is higher than the raw data, it would say "Above"; if lower, "Below"; if equal, "Same"; if raw data is not available, "NA". These 4 destinations would show up in the F,G,H columns under irrigation, livestock, aquaculture for each parameter listed. The raw data can be found on another spreadsheet (sheet 2).
View 2 Replies
View Related
Jul 5, 2009
I have two worksheets. Sheet1 is a Master List and Sheet2 is subset of Master List. Now I have to separate those records which are there in Master List, but not there is Sheet2 and list them in Sheet3.
Example:
Sheet1 contains records: a, b, c, d, e, f in rows
Sheet2 contains records: a, d, e in rows
Sheet3 must show: b, c, f in rows
View 4 Replies
View Related
Dec 7, 2012
I need to compare two worksheets, and show the final results in the Results Sheet.
These two sheets are actually .CSV files and is why some of the cells show as dates.
The SKU column is a combination of Material and Length. we need to find the difference for the Qty of SKU items.
If you look at the results page you will see what the results should be. Colored cells are just to show the differences in the example.
View 1 Replies
View Related
Jun 9, 2008
I'd like to compare 2 columns from different worksheets in the same workbook with a twist.
If any and all data from worksheet 2-column c matches any and all data from worksheet 1-column c, then go back to worksheet 2-column B on the same data matching row, copy the data from that cell and paste it into the same row of the data match in worksheet 1-column b and paste it.
View 3 Replies
View Related
Nov 4, 2013
I have a Workbook containing four different Worksheets, each of which contains a different number of columns:
"Set A" = 18 Columns
"Set B" = 47 Columns
"Set C" = 47 Columns
"Set D" = 11 Columns
Each Worksheet contains a different number of rows, approx 4,000.
Column A for each of the above Worksheets is, however, the same and contains an alphanumeric string called "Accession ID".
I have been tasked with extracting the entire row of data for each "Accession ID" which appears on at least 2 Worksheets, and then compile them in a new "Summary" Worksheet.
So, for example, if one of the Accession IDs was "ABC123" and it appeared on all four of the Worksheets; the Summary Worksheet would contain the 18 Columns from the row on which "ABC123" appeared in "Set A", the 47 Columns from the row on which "ABC123" appeared in "Set B", the 47 Columns from "Set C" and the 11 from "Set D" all on different rows.
I tried toying with VLOOKUPs etc, but given there are four Worksheets, and in order to qualify the Accession ID must only appear on a minimum of two Worksheets - it quickly become a mess.
Is there any way of being able to do this as a macro perhaps?
View 2 Replies
View Related
Jun 3, 2014
I would like to make a macro that compares two worksheets, highlights the differences, and paste the whole row in a third worksheet if a difference is found.
I managed to highlight the difference between two sheets using the following code. But how to modify it to paste the differences in a third sheet...
Code:
Sub Compare()
CompareWorksheets Worksheets("Sheet1"), Worksheets("Sheet2")
End Sub
Code:
Sub CompareWorksheets(ws1 As Worksheet, ws2 As Worksheet)
Dim diffB As Boolean
Dim r As Long, c As Integer
Dim lr1 As Long, lr2 As Long, lc1 As Integer, lc2 As Integer
Dim maxR As Long, maxC As Integer, cf1 As String, cf2 As String
[Code] ......
View 4 Replies
View Related
Apr 3, 2008
I have a workbook with two worksheets
worksheet a holds the following information
column a - employee number, column b - distribution number, column c - account number associated with the distribution number.
worksheet b holds the following information
column a - employee number, column b - check number, column c - distribution number, column d - account number associated with the distribution number
what I want is a statement that will do this:
in worksheet b, take the employee number and distribution number in row a and find the row in worksheet b that is the same, then compare the distribution numbers to see if they match.
View 12 Replies
View Related
Oct 2, 2008
I am trying to compare two worksheets and report the differences (data added or changed in the second, not necessarily data removed in the second). Afterwords I want to color code the third spreadsheet for if the whole row was added that it would make that whole row a different color and if one column in the row was changed that one column would change colors. Currently I am stumped on this, I tried searching the forums and found something that I made it to do the first part.
Sub test()
Dim a, b(), i As Long, ii As Long, n As Long, nn As Long, fa As Long
Dim z As String, zz As String
a = Sheets("sheet1").Range("a1").CurrentRegion.Resize(, 8).Value
With CreateObject("Scripting.Dictionary")
.CompareMode = vbTextCompare
For i = 2 To UBound(a, 1)
z = "": zz = ""
For ii = 1 To UBound(a, 2)
z = z & ";" & a(i, ii)
Next
zz = a(i, 5) & ";" & a(i, 6)
.Item(z) = i: .Item(zz) = i
Next .............................
View 9 Replies
View Related
Apr 24, 2007
I'm trying to do the following comparison and copy:
Step 1: See if value in Sheet1 column A matches any cell in Sheet2 column A
Step 2: If a match exists then copy value from that same row on Sheet2 column C (Min) to the same row on Sheet1 column D (Min)
Step 3: Do the same with the Max columns
For example, Sheet 1:A5 (11PL10012) matches Sheet2:A5 so copy Sheet2:C5 to Sheet1:D5 (the Min columns).
I've attached a sample spreadsheet for your review.
View 4 Replies
View Related