How can i compare the data from a sheet to another? - vba

As I have some columns with data in sheet 1 & the same column with approx. same data except some in sheet2 .So I want to compare the data from sheet1 to sheet2 & it should show something what will be easy that data is "Differ" on those cells from sheet1 to sheet2 .
By anyway I want to know where the data are different.

Lets assume your first sheet is Sheet1 and the 2nd is Sheet2,
Go to the cell a1 on Sheet2 and on home ribbon select conditional formatting -> highlight cells rules -> equal to -> and on the open window, enter the formula:
='Sheet1'!A1
press apply.
Now use the format painter brush when you are on the same cell on select all the range you have.
you can choose the color you wish to distinguish between the equal cells with non equal cells on the 'with' on the opened window

Related

Index, Match and Address functions in a formula but how do incorporate a certain condition to extract only certain data?

My Workbook has three sheets: "Wire Sheet", "Paste Data" sheet and "Wire instructions"
I need the "Wire sheet to dynamically populate with the data from the other two sheets based on certain conditions, i.e. date and data from that date.
I am using the index, match address functions to find the names from the "paste data" tab based on a specific but I can't figure out how to put a condition in there to only return names that are "buys"...
Here are my formulas:
This is just to find the cell:
S17= =MAX(IF('Paste Data'!B:B = 'Wire Sheet'!K2, ROW('Paste Data'!B:B) - ROW(INDEX('Paste Data'!B:B,1,1))+1))
S18= =ADDRESS(MATCH(K2,'Paste Data'!B:B,0),2,3,1,"Paste Data")&":"&ADDRESS(S17,5,3,1)
S19= =INDEX(S18,1)
here is the formula i am using to return the data:
=IF(INDEX(INDIRECT(S19),1,4)=0,"",INDEX(INDIRECT(S19),1,4))
Example on how spreadsheet works:
Currently: if you place a specific date in cell K2 on the "wire sheet", the boxes (cells A18:O67) populate with the data from the other two sheets based on that specific date. The data coded "Sell" is being populated in the boxes on the wire sheet, but should not be.. here is an example:
For example: If you place the date 7/13/2018 in K2 cell, the cell B57 is populated with letters SCR, which shouldn't be the case, as if you go to the "paste data" sheet, this is a "sell".
enter image description here
Then if you place the date 7/16/2018 in K2 Cell -- the cell B18 is doing the same thing, its populated with WQ when it shouldn't be, as it is a "sell", on the "paste Data" sheet. I would like it to just skip over this row of data and go and find the next row that is coded "buy"..
enter image description here
I just want to place the data that are "buys", on the wire sheet. All the sells should be passed over. I am not sure how else to explain this, which might be part of the issue.
enter image description here
Thanks in advance.
https://my.pcloud.com/publink/show?code=XZNzcB7ZpIigcTAabUz2vpPaXQ4nSVUfdc2X
+-----[editRevision2]----+
My way :
Y5 =COUNTIF('Paste Data'!B:B,'Wire Sheet'!K2)
Z6 =IF((ROW(Z6)-5)<=Y$5,ROW(Z6)-5,"")
AA6 =INDEX('Paste Data'!F:F,MATCH('Wire Sheet'!$K$2,'Paste Data'!B:B,0)+'Wire Sheet'!Z6-1,1)
AB6 =IF(AA6="Buy",AB5+1,AB5)
AC6 =IF(AA6="Buy",INDEX('Paste Data'!E:E,MATCH('Wire Sheet'!$K$2,'Paste Data'!B:B,0)+'Wire Sheet'!Z6-1),"")
AD6 =IF(AA6="Buy",INDEX('Paste Data'!K:K,MATCH('Wire Sheet'!$K$2,'Paste Data'!B:B,0)+'Wire Sheet'!Z6-1),"")
select Z6:AD6 and extend to D15, then
B18 =IFERROR(INDEX($AC:$AC,MATCH(A18,$AB:$AB,0)),"")
E19 =IFERROR(INDEX($AD:$AD,MATCH(A18,$AB:$AB,0)),"")
copy B18 to J18, B31, J31 ...
and copy E20 to J20, B33, J33 ...
+-----[ProviousEdit]----+
Make
B18 =if(SUMIFS('Paste Data'!$K:$K,'Paste Data'!$E:$E,IF(INDEX(INDIRECT(S19),1,4)=0,"",INDEX(INDIRECT(S19),1,4)),'Paste Data'!$B:$B,$K$2,'Paste Data'!$F:$F,"Buy")=0,"",IF(INDEX(INDIRECT(S19),1,4)=0,"",INDEX(INDIRECT(S19),1,4)))
and adjust the INDEX(INDIRECT(S19),1,4) accordingly for J18,B31,J31 ...
Hope that solves.. (:

Highlight a cell if its copied to another sheet

I have a formula that will copy values from one column on Sheet B to another column on another Sheet A. What I'd like to do is highlight the cells that were copied on Sheet B and highlight the cells in Sheet A that are not on Sheet B, essentially the inverse of the first part. On Sheet B only columns G and H would be highlighted but Sheet A could be from column A to H.
=IFERROR(INDEX(Sheet2!G$3:G$7,MATCH(1,INDEX((Sheet2!$D$3:$D$7=$A3)*(Sheet2!$B$3:‌​$B$7=$C3),),0)),G3)
You could set up conditional formatting with the same logic to change the colour or either the cell that you are setting or the one that you are copying from.
Beware: this kind of code can make your spreadsheet very slow if over used.
So in one range (sheet 2) , you would have conditional formatting set up to highlight the cell if
this match failed
MATCH(1,INDEX((Sheet2!$D$3:$D$7=$A3)*(Sheet2!$B$3:‌​$B$7=$C3),),0)
In the other range (sheet 1 a:h)
you would highlight if ISERROR(INDEX(Sheet2!G$3:G$7,MATCH(1,INDEX((Sheet2!$D$3:$D$7=$A3)*(Sheet2!$B$3:‌​$B$7=$C3),),0)))
has picked the value from sheet2
I may have incorrectly butchered your code, but you should get the idea. Where you currently have a range of values, select the range, insert the conditional formatting, but edit the range to only check the first cell, it will automatically increment for you (if you remove the appropriate $ signs)
conditional formatting intro

Comparing 2 excel sheets and returning a data

I'm trying to compare two Excel sheets, Sheet1 column O to Sheet2 column A:M, if it found a match, it will copy Sheet 2 "down cell of matched data" (ie match data A3, copy A4) then paste to Sheet 1 column R. I'm (very) new to VBA and Macros so I don't know how to do this. Thanks in advance!
In sheet 1 of column O - datas are USD,JPY,TWD, etc. In sheet 2 column A to M, a specified exchange rate per currency. If sheet 1 column O data is USD, it will search in Sheet 2 with matching "USD"; if cell A3's data is USD, the exchange rate is in cell A4 which will be copied and pasted into column R of Sheet 1 corresponding to the row of USD.
So what I'm dealing with is something kind of like this:
This is what I’m looking for after the macro
Since Sheet 1’s cell O1 matches Sheet 2’s cell A3, I want it to return Sheet 2’s cell A4’ s value and paste it to corresponding row of Sheet 1’s cell R1.
Let me know if this makes sense or if you need further clarification.
Thanks!
Most of the code you need you can manage by yourself using macro recorder:
Start recording new macro
Select cell O1
Copy selected cell (by pressing RMB or ctrl+C)
Go to Sheet2
Select your data (A3:M7) with mouse
Press ctrl+F to open "Find" window
Paste value of copied cell
Press Enter. Cell with searched value should be selected
Press down arrow to move selection one cell down
Copy value from selected cell
Go to Sheet1
Press right arrow to move to column R
Paste copied value
Stop recording the macro
After that you need to find how to use For loops and add it to your code. Good luck!

macro code to show much input range in dropdown list

I need a macro code to display more than one input range in dropodown list that I created in sheet2 via the form control.
I want an event with IF logic, where I have many names range from another sheet with the name eg: DaftarA (in sheet1 C1:C30), DaftarB (in sheet1 C40:C60), DaftarC (in sheet1 C70:C90).
How to write macros if the value in sheet2 C1 1, the dropdown list will display the input range of (name range) DaftarA, if the value is 2 then displayed in the dropdown list is (name range) dDftarB and so on ..
is there anything that can help? thank you
You can define a name for the list through the offset formula and use that name as a list for data validation drop down box.
=OFFSET(Sheet1!$B$1,Sheet1!$F$1,0,Sheet1!$E$1,1)
where cell B1 is top of the list, cell F1 shows how much you offset down, cell E1 will control the length of the list. It will work however only if your multiple ranges are on the same sheet and in the same column
It will also work if you define a name with the following formula
=IF(Sheet1!$F$1=1,test1,IF(Sheet1!$F$1=2,test2,IF(Sheet1!$F$1=3,test3)))
However in this case you need to name each particular range you want(like in this example test1, test2, test3) and of course you can't put too many nested formulas as it will get messy.

Insert row with data into excel sheet from another sheet dynamically

I have two different excel sheet first sheet contain some country list and second sheet is blank. There is a dropdown column with every country which contain 'Yes' 'No'. When I select yes I want that, the selected country row will automatically add to second sheet with all data. When I select more country they will dynamically insert/add to second sheet with maintaining country order in the first sheet.
These can be done with macro but I want to do this with formula.
Try this:
=IFERROR(INDEX(Sheet1!$A$1:$C$7,SMALL(IF(Sheet1!$D$1:$D$7="Yes",ROW(Sheet1!$D$1:$D$7),1E+99),ROW($A1)),COLUMN(A$1)),"")
Input formula in Cell A2 of Sheet2 and press Ctrl+Shift+Enter.
Then copy to remaining cells. Adjust the addresses in the formula to suit. HTH
Result: