Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default Simple Find/Replace Question

I know this is easy but I can't seem to figure it out, I need a macro
that will replace "NYCITY" with "NYC" if it is pasted in column 3.

Thanks,
-- Dan

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Simple Find/Replace Question

Assuming "NYCITY" is the only text in that cell:

Sub NYC ()
Dim c As Range, rng As Range
Dim Lrow as Long

Lrow = Cells(Rows.Count, 3).End(xlUp).Row
Set rng = Range("C1:C"& Lrow)

For Each c in rng
If c.Value = "NYCITY" Then c.Value = "NYC"
Next
End Sub

Mike F

"Dan R." wrote in message
ups.com...
I know this is easy but I can't seem to figure it out, I need a macro
that will replace "NYCITY" with "NYC" if it is pasted in column 3.

Thanks,
-- Dan



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default Simple Find/Replace Question

Excellent, thanks Mike.

-- Dan

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Simple Find/Replace Question

Dan,

Try this. If "NYCITY" is pasted in any row of column C, it will be replaced
by "NYC".

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 3 And Target.Text = "NYCITY" Then
Target.Value = "NYC"
End If
End Sub


"Dan R." wrote:

I know this is easy but I can't seem to figure it out, I need a macro
that will replace "NYCITY" with "NYC" if it is pasted in column 3.

Thanks,
-- Dan


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Simple Find/Replace Question

How about recording a macro when you did
select the column
edit|Replace
what: NYCITY
with: NYC
replace all

Be sure to check all the options you want so your macro can record them.

"Dan R." wrote:

I know this is easy but I can't seem to figure it out, I need a macro
that will replace "NYCITY" with "NYC" if it is pasted in column 3.

Thanks,
-- Dan


--

Dave Peterson
Reply
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
Simple Find and Replace Question Elessvie New Users to Excel 9 April 22nd 08 05:21 PM
Find & replace question.....I believe anorton Excel Discussion (Misc queries) 13 June 4th 06 01:25 PM
Simple question to find min value Tre_cool[_4_] Excel Programming 4 August 22nd 05 09:18 PM
Simple Search and Replace Question Rebecca Excel Discussion (Misc queries) 2 April 3rd 05 03:33 PM
Find/Replace Question Littlebear Excel Discussion (Misc queries) 3 February 8th 05 03:44 PM


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

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

About Us

"It's about Microsoft Excel"