The comparison needs to be done on unique id between sheet 1 and sheet 2. Both the sheet have id as a column. Need to compare this column. And delete the row in sheet 2 if there is no row for a particular id in sheet 1.
Thanks!
The comparison needs to be done on unique id between sheet 1 and sheet 2. Both the sheet have id as a column. Need to compare this column. And delete the row in sheet 2 if there is no row for a particular id in sheet 1.
Thanks!
Use countif() formula in a column and match the data with another sheet and apply filter and select 0 result and delete it
If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
Mark your thread as Solved
If the suggestion helps you, then Click *below to Add Reputation
Hi,
read VBA help of Find method and you can start to use Macro Recorder !
Edit : too late, a guru yet answered …
thanks! I actually want a VBA code. Working on a Macro.
I'm new to VBA and unable o figure out what the code should be . can anyone help me with the code. I read up about Find method but not able to delete the rows that don't match.
We need a sample workbook for giving exact vba solution
Attach a sample workbook. Make sure there is just enough data to make it clear what is needed. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are demonstrated, mock them up manually if needed. Remember to desensitize the data.
Click on GO ADVANCED and use the paperclip icon to open the upload window.
View Pic
Have uploaded a sample file. the objective is to delete the rows 2,7 and 8 from TCExecution worksheet as these test ids are not present in TCDetails Worksheet.
Thanks for all your help!!!
How to install your new code
- Copy the Excel VBA code
- Select the workbook in which you want to store the Excel VBA code
- Press Alt+F11 to open the Visual Basic Editor
- Choose Insert > Module
- Edit > Paste the macro into the module that appeared
- Close the VBEditor
- Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)
To run the Excel VBA code:Please Login or Register to view this content.
- Press Alt-F8 to open the macro list
- Select a macro in the list
- Click the Run button
when I run the macro it is opening the dialog box to select a file. and if click cancel, I get an error message and then a column with 1 is added. I already have the file open and with a few macros in it.
Two things you should remember while running the macro...
1) You have to run it from the sheet on which the deletion needs to be done.
2) Check the Comparison sheetname (i.e.) in the sample file the you named it as TCDetails so check whether any sheet exist with that name. If not then the macro will throw errors like this....
If your name of the comparison sheet is different then find this word TCDetails in the provided macro and replace it with your actual sheet name
the sheet name is the same and ran the macro from the sheet TCExecution where the deletion needs to be done. still getting this issue.
I added the code in your sample file and attaching the file for your reference. Run the code from the Sheet2 sheet.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks