Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Delete/clear a cell based on another cells contents

Could someone assist me with the following problem please.

I have a sheet that has about 1000 rows and about 50 columns. I would like
to write a macro that will clear the cell contents of 4 cells in one row IE
AC3,AD3,AE3 and BL3 based on whether the contents of cell BW3 = "Yes". The
macro will the drop to the next cell IE BW4 and will clear the contents of
the corresponding cells AC4,AD4,AE4 and BL4 if this has a "YES" in it. This
will then continue until the bottom of the sheet.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default Delete/clear a cell based on another cells contents

Here you go...

Public Sub ClearSelectContents()
Dim wks As Worksheet
Dim rngToSearch As Range
Dim rngFirst As Range
Dim rngCurrent As Range

Set wks = ActiveSheet
Set rngToSearch = wks.Range("BW3:BW65535")
Set rngCurrent = rngToSearch.Find("Yes", , , xlWhole)
If Not rngCurrent Is Nothing Then
Set rngFirst = rngCurrent
Do
rngCurrent.Offset(0, -11).ClearContents
rngCurrent.Offset(0, -44).ClearContents
rngCurrent.Offset(0, -45).ClearContents
rngCurrent.Offset(0, -46).ClearContents

Set rngCurrent = rngToSearch.FindNext(rngCurrent)
Loop Until rngCurrent.Address = rngFirst.Address
End If
End Sub

HTH

Jim Thomlinson


"jademaddy" wrote:

Could someone assist me with the following problem please.

I have a sheet that has about 1000 rows and about 50 columns. I would like
to write a macro that will clear the cell contents of 4 cells in one row IE
AC3,AD3,AE3 and BL3 based on whether the contents of cell BW3 = "Yes". The
macro will the drop to the next cell IE BW4 and will clear the contents of
the corresponding cells AC4,AD4,AE4 and BL4 if this has a "YES" in it. This
will then continue until the bottom of the sheet.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Delete/clear a cell based on another cells contents

Thanks alot.

"Jim Thomlinson" wrote:

Here you go...

Public Sub ClearSelectContents()
Dim wks As Worksheet
Dim rngToSearch As Range
Dim rngFirst As Range
Dim rngCurrent As Range

Set wks = ActiveSheet
Set rngToSearch = wks.Range("BW3:BW65535")
Set rngCurrent = rngToSearch.Find("Yes", , , xlWhole)
If Not rngCurrent Is Nothing Then
Set rngFirst = rngCurrent
Do
rngCurrent.Offset(0, -11).ClearContents
rngCurrent.Offset(0, -44).ClearContents
rngCurrent.Offset(0, -45).ClearContents
rngCurrent.Offset(0, -46).ClearContents

Set rngCurrent = rngToSearch.FindNext(rngCurrent)
Loop Until rngCurrent.Address = rngFirst.Address
End If
End Sub

HTH

Jim Thomlinson


"jademaddy" wrote:

Could someone assist me with the following problem please.

I have a sheet that has about 1000 rows and about 50 columns. I would like
to write a macro that will clear the cell contents of 4 cells in one row IE
AC3,AD3,AE3 and BL3 based on whether the contents of cell BW3 = "Yes". The
macro will the drop to the next cell IE BW4 and will clear the contents of
the corresponding cells AC4,AD4,AE4 and BL4 if this has a "YES" in it. This
will then continue until the bottom of the sheet.

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
How do I conditionally delete rows based on cell contents? John Chan Excel Worksheet Functions 3 May 17th 23 03:45 AM
Delete ROW based on Cell Contents HeatherJ Excel Discussion (Misc queries) 4 February 11th 10 04:25 PM
Clear Contents Of Cells Where Value = 0 carl Excel Worksheet Functions 3 July 6th 07 06:02 PM
How do I add a cell based on another cells contents? Debbie Excel Discussion (Misc queries) 1 December 22nd 06 06:33 PM
Delete row based on contents of cell AndyG Excel Discussion (Misc queries) 6 November 17th 05 10:08 PM


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