Hello folks;
The code below sorts my sheets by column A and then searches in column A for value 0 and changes to Unassigned. The code works, however, I just want to replace cells that only have a 0 value not those that contain 0 within the string of values. For example:
Column A before code
Maintenance
Accounting
401k
Benefits
0
Should end up after code
401k
Accounting
Benefits
Maintenance
Unassigned.
Right now it changes my 401k to 4UnassignedK
My code is as follows
The code below sorts my sheets by column A and then searches in column A for value 0 and changes to Unassigned. The code works, however, I just want to replace cells that only have a 0 value not those that contain 0 within the string of values. For example:
Column A before code
Maintenance
Accounting
401k
Benefits
0
Should end up after code
401k
Accounting
Benefits
Maintenance
Unassigned.
Right now it changes my 401k to 4UnassignedK
My code is as follows
Code:
Sub sort_Remove_Dup_CSM_Rep()
'This is Step 4 when the frmDataImportSplash is activated.
'This procedure sorts and removes all duplicates in the repname and csmname.
'This is used to manage the employee, csm list in the dasboard.
'If there is not team assigned to the account,
'go ahead and replace the empty cell with the word Unassigned
Application.ScreenUpdating = False
For Each WS In Sheets(Array("repName", "csmName", "benRepName", "departmentName"))
WS.Sort.SortFields.Clear
WS.Sort.SortFields.Add Key:=Range("A:A"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
[COLOR=#b22222] WS.Columns("A:A").Replace What:="0", Replacement:="(Unassigned)", _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False[/COLOR]
[COLOR=#b22222]With WS.Sort
[/COLOR]
.SetRange Range("A:E")
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
WS.Range("A:C").RemoveDuplicates Columns:=1, Header:=xlNo
Next WS
Application.ScreenUpdating = True
End Sub