Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default If then else assistance - conditional "deletion"

Hi all,

I'm trying to write a macro that looks in a given column of data for two
asterisks (**), for instance. If this macro encounters a cell with **
anywhere within its contents, it should delete the entire contents of
the cell including the asterisks. I need the desired column of data to
be user defined as well.

Does anyone know how I would go about creating this?

Any advice would be appreciated.

Many thanks,

Kelly



*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default If then else assistance - conditional "deletion"

To be clear, I don't want to delete the cell - only the contents within
the cell.

My title is misleading - apologies.



*** Sent via Developersdex http://www.developersdex.com ***
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default If then else assistance - conditional "deletion"

You could record a macro when you do:
Select the column
Edit|Replace
what: *~*~**
with: (leave blank)
replace all


This is what the code would look like to search for ** in the entire column of
the activecell.

ActiveCell.EntireColumn.Replace _
What:="*~*~**", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False

Since * serves as a wild card, you specify an "escape" character telling excel
that you really mean the asterisk (~*).

So *~*~**
is
(wildcard)(real asterisk)(real asterisk)(wildcard)

The same technique works when you want to change (or find) a question mark: ~?

(and ~~ for a real tilde)

Kelly wrote:

Hi all,

I'm trying to write a macro that looks in a given column of data for two
asterisks (**), for instance. If this macro encounters a cell with **
anywhere within its contents, it should delete the entire contents of
the cell including the asterisks. I need the desired column of data to
be user defined as well.

Does anyone know how I would go about creating this?

Any advice would be appreciated.

Many thanks,

Kelly

*** Sent via Developersdex http://www.developersdex.com ***


--

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
Excel 2003: Conditional Formatting using "MIN" & "MAX" function MMangen Excel Discussion (Misc queries) 2 September 16th 08 07:13 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
inserting a conditional "go to" command on a excel "if" function velasques Excel Worksheet Functions 5 March 10th 06 08:16 PM
conditional formula to show "open" or "closed" SBS Excel Worksheet Functions 6 January 28th 06 01:48 AM
excel should "paste special" a "conditional formatting" lozturk21 Excel Programming 0 October 23rd 05 02:15 PM


All times are GMT +1. The time now is 11:01 PM.

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"