+ Reply to Thread
Results 1 to 5 of 5

Macro

  1. #1
    Paul H
    Guest

    Macro

    I have created a simple macro that when used will clear out the contents of a
    certain cells. If I insert an additional row the macro does not adjust and
    the macro needs to be edited. Is there a way to have the macro adjust
    automatically when a row is insurted?

  2. #2
    Jim Thomlinson
    Guest

    RE: Macro

    Nope. The Macro is what it is... You need to change the macro to dynamically
    determine what it needs to do, not clear the contenst of a "Hard Coded" cell.
    I would need to see the code and get a few more details to help you...

    "Paul H" wrote:

    > I have created a simple macro that when used will clear out the contents of a
    > certain cells. If I insert an additional row the macro does not adjust and
    > the macro needs to be edited. Is there a way to have the macro adjust
    > automatically when a row is insurted?


  3. #3
    Paul H
    Guest

    RE: Macro

    Can a macro be written that would clear the contents from all yellow cells?

    "Jim Thomlinson" wrote:

    > Nope. The Macro is what it is... You need to change the macro to dynamically
    > determine what it needs to do, not clear the contenst of a "Hard Coded" cell.
    > I would need to see the code and get a few more details to help you...
    >
    > "Paul H" wrote:
    >
    > > I have created a simple macro that when used will clear out the contents of a
    > > certain cells. If I insert an additional row the macro does not adjust and
    > > the macro needs to be edited. Is there a way to have the macro adjust
    > > automatically when a row is insurted?


  4. #4
    Gary Brown
    Guest

    RE: Macro

    Paul,
    If you create a range containing those certain cells then inserting or
    deleting a row or column will adjust the range. In a macro, reference the
    range name instead of the individual cells.
    For example:

    If you created a range name called TEMP in A1:A2 (Insert / Name / Define),
    then insert a row at at row 2, the range TEMP will know that the new range is
    A1:A3. An example of using a range instead of cell addresses would be...
    Range("TEMP").Copy
    Range("D1").Select
    ActiveSheet.Paste

    Hope this helps,
    Gary Brown


    "Paul H" wrote:

    > I have created a simple macro that when used will clear out the contents of a
    > certain cells. If I insert an additional row the macro does not adjust and
    > the macro needs to be edited. Is there a way to have the macro adjust
    > automatically when a row is insurted?


  5. #5
    Gary Brown
    Guest

    RE: Macro

    Yes,
    Sub test()
    Dim cell As Range
    For Each cell In Selection
    If cell.Interior.ColorIndex = 6 Then
    cell.ClearContents
    End If
    Next cell
    End Sub

    6 is bright yellow
    36 is light yellow

    or using Range Names...
    Sub test()
    Dim cell As Range
    For Each cell In Range("TEST")
    If cell.Interior.ColorIndex = 6 Then
    cell.ClearContents
    End If
    Next cell
    End Sub

    HTH,
    Gary Brown


    "Paul H" wrote:

    > Can a macro be written that would clear the contents from all yellow cells?
    >
    > "Jim Thomlinson" wrote:
    >
    > > Nope. The Macro is what it is... You need to change the macro to dynamically
    > > determine what it needs to do, not clear the contenst of a "Hard Coded" cell.
    > > I would need to see the code and get a few more details to help you...
    > >
    > > "Paul H" wrote:
    > >
    > > > I have created a simple macro that when used will clear out the contents of a
    > > > certain cells. If I insert an additional row the macro does not adjust and
    > > > the macro needs to be edited. Is there a way to have the macro adjust
    > > > automatically when a row is insurted?


+ 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