Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Clearing Contents | Excel Discussion (Misc queries) | |||
Clearing contents not formatting | Excel Discussion (Misc queries) | |||
clearing the contents of specified cells | Excel Programming | |||
Clearing Contents | Excel Programming | |||
Clearing Contents of Cell | Excel Worksheet Functions |