ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Clear contents with condition (https://www.excelbanter.com/excel-programming/356906-clear-contents-condition.html)

Vanna

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.

Henrich

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.


EvolBob

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.


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com