July 29, 2018
Hello Everyone, I am looking for a macro plz see the details below
Condition 1) Only If column K of sample1.xls is greater than Column D of sample1.xls & Column H of sample1.xls is Greater than column K of sample1.xls then Match Column B of sample1.xls with column B of sample2.csv & if it is there then do nothing & if it is not present then paste the column B data of sample1.xls to column B of sample2.csv
Condition 2) Only If column K of sample1.xls is lower than Column D of sample1.xls & Column H of sample1.xls is lower than column K of sample1.xls then Match Column B of sample1.xls with column B of sample2.csv & if it is there then do nothing & if it is not present then paste the column B data of sample1.xls to column B of sample2.csv
Plz Note
All files are located in a different path (So in the macro the path will be hardcoded, Assume any path & I will edit the path manually by myself)
Sheet name can be anything
Macro will be putted in a vba.xlsm
Plz see the file that I have attached below
Trusted Members
December 20, 2019
Hi Sholtan
This is quite simular the last few questions you have posted in the forum - have you tried to create it yourself?
While the actual process of opening files etc are straight forward the comparisons you want to make are quite complex.
You seem happy enough to edit code, so i assume you are willing to learn to code your own stuff and once you start you wont want to stop.
As a pointer, i would open the xls file and then import the csv into the same workbook, you can then use standard formulas to do the comparisons you want to and then save the output as a new workbook. All a macro is doing is automating the manual steps - you just need to work through each issue as they happen.
To open a workbook
Sub OpenWb()
Workbooks.Open ("C:\MOTH\sample1.xls")
End Sub
To open the csv and copy to sample1.xls (made a bit more complicated by the .xls to start with rather than a .xlsx)
Sub Opencsvandcopy()
Workbooks.Open ("C:\MOTH\sample2.csv")
Worksheets("sample2").Range("a1:k5").Copy
Workbooks("sample1.xls").Sheets.Add.Name = "sample2"
Workbooks("sample1.xls").Worksheets("sample2").Range("a1").PasteSpecial xlPasteAll
End Sub
I hope this helps
Purfleet
July 29, 2018
This is not possible, that this question is homework
whenever i ask question, u say this seems like homework
I face issues in making the macro,in which csv files are present, so that's y i always ask the question related to csv files
Purfleet Sir i am unable to make the macro for this
So plz have a relook & provide me the completed code
Trusted Members
December 20, 2019
Hi Sholtan
I am happy to help but my time is limited, i have started you off with the automated import into Excel. Can you figure out the logic to do what you want (even if it was with formulas)?
Then post it back on here and i might be able to automate.
As i said before, it is simular to the last question you asked, so maybe there are lessons to be lernt from that thread?
Purfleet
July 29, 2018
Either of these 2 conditions are to result in macro will copy value in column I of sample1.xls to field 2(column B) of Sample2.csv on a new line:
Condition 1) Only If column K of sample1.xls is greater than Column D of sample1.xls & Column H of sample1.xls is Greater than column K of sample1.xls then Match Column I of sample1.xls with second field values (column B) of sample2.csv & if it is there then do nothing & if it is not present then paste the column I data of sample1.xls to append second field values (column B) of sample2.csv
Condition 2) Only If column K of sample1.xls is lower than Column D of sample1.xls & Column H of sample1.xls is lower than column K of sample1.xls then Match Column I of sample1.xls with second field values (column B) of sample2.csv & if it is there then do nothing & if it is not present then paste the column I data of sample1.xls to append second field values (column B) of sample2.csv
1 Guest(s)