1 Attachment(s)
[RESOLVED] clear the data by vba macro
Hi,
Macro will be placed in macro.xlsm & book1.xlsx & Book2.xlsx are located at different place so the path of of both the files should be hardcoded in the macro
If cells in column A of sheet1 of book2.xlsx matches with cells of column A of book1.xlsx then dont do anything & If it doesnt matches then clear all the data in that row of book2.xlsx from column B
(clear all the data in that row of book2.xlsx from column B means from column B till the end of data we have to clear all the data in that unmatched cells in that row,we will not do anything with column A data)
Thnx
Re: clear the data by vba macro
i am currently unable to open your samples, but based on your description
Code:
p1 = "c:\temp\"
p2 = "C:\temp\"
Set wb1 = Workbooks.Open(p1 & "book1.xlsx")
Set wb2 = Workbooks.Open(p2 & "book2.xlsx")
For Each cel In wb2.Sheets(1).Range("a:a")
If IsEmpty(cel) Then Exit For ' stop on empty cell
Set fnd = wb1.Sheets(1).Range("a:a").Find(cel)
If fnd Is Nothing Then cel.Offset(, 1).Resize(, Columns.Count - 1).Clear
Next
i will try to find a machine with a later version of excel, to test
Re: clear the data by vba macro
Thnx Alot westconn1 Sir for helping me in solving this Problem Sir
Have a Awesome Day Sir