Replace Data in Table based on result of IF Statement

JTL9161

Well-known Member
Joined
Aug 29, 2012
Messages
567
Office Version
  1. 365
Platform
  1. Windows
I have a table (20 rows, 3 columns) with various data. I have 20 other cells with if statements that will result in 2 possible options, for example either AAA-1 or AAA-2 will be the result of the if statement. Not all the if statements are completed at the same time. What I am asking is when and IF statement comes up with an answer say AAA-2 I am looking to delete all the "AAA-2" from the 20 row 3 column table and do so every time an if statement comes up with one of it 2 possible answers.


AAA-1 AAA-3 AAA-2
AAA-2 AAA-1 AAA-4
AAA-3 AAA-2 AAA-5

I am looking for the result of

AAA-1 AAA-3
AAA-1 AAA-4
AAA-3 AAA-5


Thank you,
James
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Here is an sample code assuming your table starts on A1 with no headers.
VBA Code:
Sub myFunction()
  For r = 1 To 20 'Must be your row addresses
    For c = 1 To 3 'Must be your coulmn addresses
      If Cell(r, c).Value = "AAA-2" Then
        Select Case i
        Case 1
          Cell(r, c).Value = Cell(r, c+1).Value
          Cell(r, c+1).Value = Cell(r, c+2).Value
          Cell(r, c+2).Value = ""
        Case 2
          Cell(r, c).Value = Cell(r, c+1).Value
          Cell(r, c+1).Value = ""
        Case 3
          Cell(r, c).Value = ""
        End Select
      End If
    Next
  Next
End Sub
 
Upvote 0
Sorry, I was looking for a formula not a VBA
 
Upvote 0
A formula cannot delete data from other cells.
 
Upvote 0

Forum statistics

Threads
1,214,784
Messages
6,121,540
Members
449,038
Latest member
Guest1337

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top