Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
I have already received some great advice on here on how to name a field, but I have a question in regards to the code. The following code searches a 2 columns where column B has repeated departments, and names the field of job positions in Column C. It creates a names based on column B. In the code, it replaces " " with "". How can I also use the code and replace a few other characters with "", such as / - ' ? I have tried everything...help lRow = Cells(Rows.Count, 2).End(xlUp).Row + 1 Set colB = Range(Cells(2, 2), Cells(lRow, 2)) Dept = Trim(Cells(2, 2).Value) newDept = Replace(Dept, " ", "") sRow = 2 eRow = 2 For Each chk In colB If chk.Value < Dept Then ActiveWorkbook.Names.Add Name:=newDept, _ RefersToR1C1:="=Data!R" & sRow & "C3:R" & eRow & "C3" Dept = chk.Value newDept = Replace(Dept, " ", "") sRow = chk.Row eRow = chk.Row Else eRow = chk.Row End If Next chk End Sub Thanks!! Mike |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Replacing certain characters in a cell | Excel Worksheet Functions | |||
Replacing ascii characters | Excel Worksheet Functions | |||
Replacing specific characters | Excel Discussion (Misc queries) | |||
Replacing characters | Excel Programming | |||
Replacing characters | Excel Worksheet Functions |