+ Reply to Thread
Results 1 to 12 of 12

Need Macro to find cell and insert a row above it.

  1. #1
    Registered User
    Join Date
    01-22-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    26

    Need Macro to find cell and insert a row above it.

    I am totally new to this stuff. I can usually find a macro and change it to fit what I need, but this time I am stuck.

    What I am trying to do is create a macro that searches for a specific highlighted cell, then insert a row above it, and delete the highlighted cell. Hope that makes sense.

    Thank you

    Rachel
    Attached Images Attached Images

  2. #2
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Need Macro to find cell and insert a row above it.

    Will the highlighted cell always in a particular column or can the cell occur anywhere on the worksheet?
    If you like my contribution click the star icon!

  3. #3
    Registered User
    Join Date
    01-22-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: Need Macro to find cell and insert a row above it.

    It will always be in Column C

  4. #4
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Need Macro to find cell and insert a row above it.

    Try (you will need to find the RGB values for the color green, select the cell click more colors and click custom to see the RGB values for the color green that you are using).

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-22-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: Need Macro to find cell and insert a row above it.

    I can't get it to work. I used conditional formatting if that makes any difference on the Interior.color

    Columns("C:C").Select
    Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreater, _
    Formula1:="=0.208333333333333"
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Interior
    .PatternColorIndex = xlAutomatic
    .Color = 5296274
    .TintAndShade = 0
    End With
    Selection.FormatConditions(1).StopIfTrue = False
    End Sub

    Thank you for all your help.

  6. #6
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Need Macro to find cell and insert a row above it.

    I am on my iPad now so I cannot check whether conditional formatting makes a difference. Have you tried replacing the RGB() instruction with the value 5296274 yet?

  7. #7
    Registered User
    Join Date
    01-22-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: Need Macro to find cell and insert a row above it.

    Yes, if I put RGB(5296274) I get a compile error. If I remove RGB and leave (5296274) - nothing happens and if I leave only 5296274 nothing happens.

  8. #8
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Need Macro to find cell and insert a row above it.

    Ok. Can we instead use the value that triggers the conditional format? For example find a cell with a timestamp > 16:00 and do.... Would that be n option?

  9. #9
    Registered User
    Join Date
    01-22-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: Need Macro to find cell and insert a row above it.

    Yes, anything greater than 5:00 would also work.

  10. #10
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Need Macro to find cell and insert a row above it.

    Ok

    Replace

    Please Login or Register  to view this content.
    With

    Please Login or Register  to view this content.
    I cannot test this right now, but I think this should work

  11. #11
    Registered User
    Join Date
    01-22-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: Need Macro to find cell and insert a row above it.

    OMG it worked. Thank you, thank you....

    Rachel

  12. #12
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Need Macro to find cell and insert a row above it.

    Glad to have been of assistance. Please remember to mark your thread as solved and to click on the star icon if you are happy with my contribution.

+ 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