Hello,
Need some assistance, I have the below code, but I'm trying to figure out two things. 1) If cell value in column BE = cell value in column BG, then cell value in column BG should be replaced with blank. 2) If cell value in column BE is included within the text string in column BG, then replace that value in string only to "".
BG being J in the code and BE being K in the code (saved ranges within the code).
Full Code:
Below is the part of the code I'm trying to solve for ... if BE = BG, then BG should be blank and then add another condition where if value in BE is included in column BG, then the value form BE should be removed from column BG. However, the code I have now is replacing every value in column BG as blanks. No sure what I am missing or doing wrong here. Provided a table below with a small sample data.
Thank you,
Need some assistance, I have the below code, but I'm trying to figure out two things. 1) If cell value in column BE = cell value in column BG, then cell value in column BG should be replaced with blank. 2) If cell value in column BE is included within the text string in column BG, then replace that value in string only to "".
BG being J in the code and BE being K in the code (saved ranges within the code).
Full Code:
VBA Code:
Sub CleanUpBusImp()
Dim sh As Worksheet
Dim lr As Long
Dim i&, rngF, rngJ, rngK, F As String, J As String, K As String, CleanBusImp()
Set sh = Sheets("Main")
lr = sh.Range("A" & Rows.Count).End(xlUp).Row
rngF = Range("BD3:BD" & lr).Value: rngJ = Range("BG3:BG" & lr).Value: rngK = Range("BE3:BE" & lr).Value
ReDim CleanBusImp(1 To UBound(rngJ), 1 To 1)
For i = 1 To UBound(rngJ)
F = rngF(i, 1): J = rngJ(i, 1): K = rngK(i, 1)
Select Case True
Case (F Like "Shared Non-O&T")
'Case (F <> "Business")
CleanBusImp(i, 1) = Replace(Replace(Replace(Replace(Replace(Replace(Replace(J, "/EO&T", ""), "/LF - PBWM O&T", ""), "LF - PBWM O&T/", ""), "/PBWM O&T", ""), "/ICG O&T", ""), "PBWM O&T/", ""), "EO&T/", "")
If J = "LF - PBWM O&T" Then
CleanBusImp(i, 1) = "LF - PBWM Operations/LF - PBWM Technology"
ElseIf J = "PBWM O&T" Then
CleanBusImp(i, 1) = "PBWM Operations/PBWM Technology"
ElseIf J = "ICG O&T" Then
CleanBusImp(i, 1) = "ICG Operations/ICG Technology"
End If
Case (F <> "Business") And (F <> "Shared Non-O&T")
CleanBusImp(i, 1) = Replace(Replace(Replace(Replace(Replace(Replace(Replace(J, "/EO&T", ""), "/LF - PBWM O&T", ""), "LF - PBWM O&T/", ""), "/PBWM O&T", ""), "/ICG O&T", ""), "PBWM O&T/", ""), "EO&T/", "")
If K = J Then
'CleanBusImp(i, 1) = ""
J = ""
End If
End Select
Next
With Range("BG3").Resize(UBound(rngJ), 1)
.ClearContents
.Value = CleanBusImp
End With
End Sub
Below is the part of the code I'm trying to solve for ... if BE = BG, then BG should be blank and then add another condition where if value in BE is included in column BG, then the value form BE should be removed from column BG. However, the code I have now is replacing every value in column BG as blanks. No sure what I am missing or doing wrong here. Provided a table below with a small sample data.
VBA Code:
Case (F <> "Business") And (F <> "Shared Non-O&T")
CleanBusImp(i, 1) = Replace(Replace(Replace(Replace(Replace(Replace(Replace(J, "/EO&T", ""), "/LF - PBWM O&T", ""), "LF - PBWM O&T/", ""), "/PBWM O&T", ""), "/ICG O&T", ""), "PBWM O&T/", ""), "EO&T/", "")
If K = J Then
'CleanBusImp(i, 1) = ""
J = ""
End If
L2_Business | Business_Impacted | Result |
Business 1 | Business 1/Business 4 | Business 4 |
Business 1 | Business 1 | |
Business 2 | Business 2/Business 3/Business 5 | Business 3/Business 5 |
Business 1 | Business 1 | |
Business 2 | Business 4/Business 3/Business 2/Business 5 | Business 4/Business 3/Business 5 |
Thank you,