LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Naming field & replacing characters

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Replacing certain characters in a cell Mary Lou[_2_] Excel Worksheet Functions 3 March 5th 08 09:40 PM
Replacing ascii characters HappyCamper Excel Worksheet Functions 2 February 8th 06 07:10 PM
Replacing specific characters Trey Excel Discussion (Misc queries) 3 January 20th 06 11:57 PM
Replacing characters Phil Floyd[_2_] Excel Programming 2 July 29th 05 01:17 PM
Replacing characters OhhAhh Excel Worksheet Functions 10 March 4th 05 12:28 AM


All times are GMT +1. The time now is 05:05 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"