VBA if this column in a table has this put text in other cell

cizzett

Board Regular
Joined
Jan 10, 2019
Messages
121
So I have a formula in the column Max Boxes in my table, I am trying to get it to put the text in my column "Dest Loc ID" which is -6 columns from the range we are looking in.

The formula in the Max Boxes column will place an EDC or WDC in the column depending on criteria in other column but I want to insert EDC/WDC if this is it is marked as EDC or WDC.

Below is my attempt but it marks all the cells in my -6 column ("DEST LOC ID") as EDC/WDC

Code:
Sub EDCWDC()

    Dim SWb As Workbook: Set SWb = ThisWorkbook
    Dim SS As Worksheet: Set SS = SWb.Sheets("Steri Sheet")
    Dim ST As ListObject: Set SS = SWb.Sheets("Steri Sheet")
    Dim SteriS As Range: Set SteriS = Range("SteriTable[Max Boxes]")
    Dim rng As Range
    For Each rng In SteriS
        If rng.Cells.Value <> "EDC" Then
            rng.Offset(0, -6) = "EDC/WDC"
        End If
    If rng.Cells.Value <> "WDC" Then
        rng.Offset(0, -6) = "EDC/WDC"
        End If
    Next rng
   
End Sub
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Try
Code:
For Each Rng In SteriS
   If Rng.Value = "EDC" Or Rng.Value = "WDC" Then
      Rng.Offset(0, -6) = "EDC/WDC"
   End If
Next Rng
 
Last edited:
Upvote 0
Fluff, You are the man indeed.

Works Perfect I guess I was making it too difficult.

Thanks as always.
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,905
Messages
6,175,297
Members
452,633
Latest member
DougMo

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