Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Zak Zak is offline
external usenet poster
 
Posts: 144
Default Clearing contents

Hi,

Hope u can help me..

I would like to know how i can tell a macro to clear contents when:

If a cell in column E is NOT blank then clear the contents of that entire
row (but NOT delete the row), and i want to start looking for non blanks
after the header row to avoid the hearder getting cleared.

thanks for your help.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default Clearing contents

One way..
Sub Zak()
Dim lRow As Long, r As Long
lRow = Cells.Find(what:="*", After:=[A1], _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
For r = 2 To lRow
If Not IsEmpty(Range("E" & r)) Then _
Range("E" & r).EntireRow.ClearContents
Next r
End Sub

On May 12, 10:36*am, Zak wrote:
Hi,

Hope u can help me..

I would like to know how i can tell a macro to clear contents when:

If a cell in column E is NOT blank then clear the contents of that entire
row (but NOT delete the row), and i want to start looking for non blanks
after the header row to avoid the hearder getting cleared.

thanks for your help.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Clearing contents

Hi

Look at this:

Sub ClearRow()
Dim TargetRange As Range
Set TargetRange = Range("E2", Range("E65536").End(xlUp))

For Each c In TargetRange
If c.Value < "" Then c.EntireRow.ClearContents
Next
End Sub

Regards,
Per

"Zak" skrev i meddelelsen
...
Hi,

Hope u can help me..

I would like to know how i can tell a macro to clear contents when:

If a cell in column E is NOT blank then clear the contents of that entire
row (but NOT delete the row), and i want to start looking for non blanks
after the header row to avoid the hearder getting cleared.

thanks for your help.


  #4   Report Post  
Posted to microsoft.public.excel.programming
Zak Zak is offline
external usenet poster
 
Posts: 144
Default Clearing contents

Thanks guys its worked a treat, appreciate the prompt reply.

"Per Jessen" wrote:

Hi

Look at this:

Sub ClearRow()
Dim TargetRange As Range
Set TargetRange = Range("E2", Range("E65536").End(xlUp))

For Each c In TargetRange
If c.Value < "" Then c.EntireRow.ClearContents
Next
End Sub

Regards,
Per

"Zak" skrev i meddelelsen
...
Hi,

Hope u can help me..

I would like to know how i can tell a macro to clear contents when:

If a cell in column E is NOT blank then clear the contents of that entire
row (but NOT delete the row), and i want to start looking for non blanks
after the header row to avoid the hearder getting cleared.

thanks for your help.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Clearing contents

Try this:

Sub eclear()
n = Cells(Rows.Count, "E").End(xlUp).Row
For i = 2 To n
If IsEmpty(Cells(i, "E")) Then
Else
Cells(i, "E").EntireRow.Clear
End If
Next
End Sub

--
Gary''s Student - gsnu200785


"Zak" wrote:

Hi,

Hope u can help me..

I would like to know how i can tell a macro to clear contents when:

If a cell in column E is NOT blank then clear the contents of that entire
row (but NOT delete the row), and i want to start looking for non blanks
after the header row to avoid the hearder getting cleared.

thanks 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
Clearing Contents AMANDA Excel Discussion (Misc queries) 2 July 6th 09 05:34 PM
Clearing contents not formatting JSnow Excel Discussion (Misc queries) 3 August 13th 08 04:26 PM
clearing the contents of specified cells Jimmy Pop Excel Programming 5 May 27th 05 01:17 AM
Clearing Contents Sean Excel Programming 5 May 6th 05 05:16 PM
Clearing Contents of Cell Burt Excel Worksheet Functions 1 May 4th 05 02:46 PM


All times are GMT +1. The time now is 12:46 PM.

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"