+ Reply to Thread
Results 1 to 7 of 7

Delete row data and cell colour

  1. #1
    Registered User
    Join Date
    08-14-2006
    Posts
    32

    Delete row data and cell colour

    Is it possible to write a macro for say if cell A1 is equal to say word such as sick, then the cells b1-g1 would have all data removed?

  2. #2

    Re: Delete row data and cell colour

    Sure...


    If Range("A1").Value = "sick" Then
    Range("B1:G1").ClearContents
    End If



    alex1982 wrote:
    > Is it possible to write a macro for say if cell A1 is equal to say word
    > such as sick, then the cells b1-g1 would have all data removed?
    >
    >
    > --
    > alex1982
    > ------------------------------------------------------------------------
    > alex1982's Profile: http://www.excelforum.com/member.php...o&userid=37494
    > View this thread: http://www.excelforum.com/showthread...hreadid=573248



  3. #3
    Jim May
    Guest

    Re: Delete row data and cell colour

    Without using the Lcase() twice below in the code presented
    "Sick" is not "sick"
    "SICK" is not "Sink"
    etc...
    So I'd use:

    Sub tester()
    If LCase(Range("A1").Value) = LCase("sick") Then
    Range("B1:G1").ClearContents
    End If
    End Sub




    "[email protected]" wrote:

    > Sure...
    >
    >
    > If Range("A1").Value = "sick" Then
    > Range("B1:G1").ClearContents
    > End If
    >
    >
    >
    > alex1982 wrote:
    > > Is it possible to write a macro for say if cell A1 is equal to say word
    > > such as sick, then the cells b1-g1 would have all data removed?
    > >
    > >
    > > --
    > > alex1982
    > > ------------------------------------------------------------------------
    > > alex1982's Profile: http://www.excelforum.com/member.php...o&userid=37494
    > > View this thread: http://www.excelforum.com/showthread...hreadid=573248

    >
    >


  4. #4
    Registered User
    Join Date
    08-14-2006
    Posts
    32
    Can i also get it to clear the cell colour?

  5. #5
    Jim May
    Guest

    Re: Delete row data and cell colour

    What cell color? You don't furnish any details, such as:
    What cells are colored? Cell Addresses, please
    How are they colored? 1) Manually using Fill-Color Icon
    or 2) using Conditional Formatting?


    "alex1982" wrote:

    >
    > Can i also get it to clear the cell colour?
    >
    >
    > --
    > alex1982
    > ------------------------------------------------------------------------
    > alex1982's Profile: http://www.excelforum.com/member.php...o&userid=37494
    > View this thread: http://www.excelforum.com/showthread...hreadid=573248
    >
    >


  6. #6
    Registered User
    Join Date
    08-14-2006
    Posts
    32
    A1 is a drop down menu with 2 choice. when nothing is selected i want to be able to choose the cell colours of B1-G1 myself. as i have a macro to count cells by cell colour. However, when one of these options is selected i want it to delete all the cell info and colours from B1-G1.

  7. #7

    Re: Delete row data and cell colour

    Sure thing, add one (or both) of these lines:


    Range("B1:G1").Interior.ColorIndex = xlNone 'clears background
    color
    Range("B1:G1").Font.ColorIndex = 0 'set font color to Automatic

    Your request seems pretty straight-forward to me.

    alex1982 wrote:
    > A1 is a drop down menu with 2 choice. when nothing is selected i want to
    > be able to choose the cell colours of B1-G1 myself. as i have a macro to
    > count cells by cell colour. However, when one of these options is
    > selected i want it to delete all the cell info and colours from B1-G1.
    >
    >
    > --
    > alex1982
    > ------------------------------------------------------------------------
    > alex1982's Profile: http://www.excelforum.com/member.php...o&userid=37494
    > View this thread: http://www.excelforum.com/showthread...hreadid=573248



+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1