Hello
I need to compare two workbook, but only the first column. and not from the first letter, from the 11. letter. And i don't know how can i do that.
Hello
I need to compare two workbook, but only the first column. and not from the first letter, from the 11. letter. And i don't know how can i do that.
the first workbook, from the first letter, and the second workbook from the 11. letter in column A
Please attach a sample workbook so we understand your requirement.
To Attach a File:
1. Click on Go Advanced.
2. In the frame Attach Files you will see the button Manage Attachments
3. Click the button.
4. A new window will open titled Manage Attachments - Excel Forum.
5. Click the Browse... button to locate your file for uploading.
6. This will open a new window File Upload.
7. Once you have located the file to upload click the Open button. This window will close.
8. You are now back in the Manage Attachments - Excel Forum window.
9. Click the Upload button and wait until the file has uploaded.
10. Close the window and then click Submit.
If I have helped, Don't forget to add to my reputation (click on the star below the post)
Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
Use code tags when posting your VBA code: [code] Your code here [/code]
i cant upload files, from my workplace
forexample
workbook1 - Column A
world1
world2
world3
world4
...etc
workbook2 - column A
hello_world1
1245_world2
kjgh_world3
dlle_world4
.... etc
do you understand it?
After comparing, what output do you need?
i need to know, how many data equals in the two workbook2 with the workbook1
there is data in the workbook2, that is not in the workbook1
(sorry if iam write wrong, iam not so good in english)
Ok, i understood you .
One more question - will world1 in workbook1 be in the same row as hello_world1 in workbook2? Will the entries be in the same row so they can be matched or they can be anywhere in the column?
no, unfortunately its not in the same row :/
can you help me? i have to do this today :/
Try this codeFor this example, i have saved the files as workbook1.xlsx and workbook2.xlsm. The macro needs to be saved in the 2nd workbook. The macro assumes that workbook1 is also open at the time of running the macro.Please Login or Register to view this content.
Copy the Excel VBA code
Select the 2nd workbook in which you need to store the Excel VBA code
Hold the Alt key, and press the F11 key, to open the Visual Basic Editor
Choose Insert | Module
Where the cursor is flashing, choose Edit | Paste
To run the Excel VBA code:
Choose Tools | Macro | Macros
Select a macro in the list, and click the Run button
Let me explain to you what it does:
1. Since the format of both the files is not same, a column is inserted in column A of workbook2. Using formulae such as len, right, find, only the world1, world2, etc part of the text is inserted into column A.
2. Another column is inserted in column B. Here the number 2 is inserted to show that the data has come from workbook2.
3. The data from workbook1 is copied in column A below the existing data. In column B, the number 1 is inserted for each row belonging to workbook1.
4. The data is sorted based on column A.
5. A condition is applied to the data - If row 1 and row 2 match, then the word "Same" is entered in column D, if not, the word "New" is entered.
Hope this works for you. Please try it on a copy of your file.
i dont know yet exactly how it works, but its thow az exepction to this line
If .Range("A" & i).Value = .Range("A" & i + 1).Value And .Range("B" & i).Value <> .Range("B" & i + 1).Value Then
Run time error '13': Type mismatch
i rewrite only the file name
What are the values you have in columns A & B? Are they the same as what you posted in this thread?
the datas are in two excel workbook, not two worksheet, and in the B, C, D....columns are other datas.
Yes, it should work with 2 excel workbooks. What do you have in columns B, C & D? There is some data in there that is causing the macro not to work. See if you can attach a sample file, or else it will be tough to troubleshoot the problem.
i sad i cant upload files
in workbook1 in column B-H are numbers
in workbook2 in column B-D are other numbers
The macro inserts columns in A & B. So ideally your data in B-D will now move forward to D-F. So the macro should not be posing any problems.
If its still posing problems, i can have the comparison done in a temp worksheet. What do you suggest?
Yes, please, do the comparison in a temp worksheet.
Thanks
Try this code which creates a "Temp" sheet and does the calculations.Please Login or Register to view this content.
it's still trow an exeption to this line :/
If .Range("A" & i).Value = .Range("A" & i + 1).Value And .Range("B" & i).Value <> .Range("B" & i + 1).Value Then
runtime error 13
Type mismatch
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks