Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Clear contents with condition

Hi everyone,

I'm a novice user in Excel Macros... still a lot more to be learn.
I need to write a code to clear cell contents under from column H if the
cell contains "("

I used:

Range = €œH:H€
For each cell in range
If substring of cell.value=")" then
cells.ClearContents
next

In advance, thank you for your help.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Clear contents with condition

Hi, i'm using this (there are other options to do this):

Sub Clear()
Row = 1
Do Until Cells(Row, 8) = ""
Text = Cells(Row, 8)
If Text = """(""" Then Cells(Row, 8).ClearContents
Row = Row + 1
Loop
End Sub

This code is searching for your string until it reach first empty cell in
column H.

Henrich

€žVanna" napÃ*sal (napÃ*sala):

Hi everyone,

I'm a novice user in Excel Macros... still a lot more to be learn.
I need to write a code to clear cell contents under from column H if the
cell contains "("

I used:

Range = €œH:H€
For each cell in range
If substring of cell.value=")" then
cells.ClearContents
next

In advance, thank you for your help.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Clear contents with condition

Hi Vanna - I never use something as a variable that is too similar to a reserved word and Cells is one of them.
Personally I'd use ....

Sub RemoveH()
Dim c As Range
For Each c In [H1].Resize([H65536].End(xlUp).Row, 1).Cells
If Not Application.IsError(Application.Find("(", _
c.Value)) Then c.Value = ""
Next c
End Sub


Regards
Robert McCurdy

"Vanna" wrote in message ...
Hi everyone,

I'm a novice user in Excel Macros... still a lot more to be learn.
I need to write a code to clear cell contents under from column H if the
cell contains "("

I used:

Range = €œH:H€
For each cell in range
If substring of cell.value=")" then
cells.ClearContents
next

In advance, thank you for your help.
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
Clear Contents gibbylinks Setting up and Configuration of Excel 5 October 12th 09 05:04 PM
Clear contents of cells if a condition is met bevchapman Excel Worksheet Functions 2 March 16th 09 03:45 PM
Clear Contents Secret Squirrel Excel Discussion (Misc queries) 1 February 3rd 09 12:37 AM
Macro clear cells if meet 1 condition Sojo Excel Worksheet Functions 8 October 20th 08 02:38 PM
Clear contents if x is not in the row Mighvik Excel Programming 1 October 5th 04 08:14 PM


All times are GMT +1. The time now is 10:45 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"