+ Reply to Thread
Results 1 to 3 of 3

VBA to highlight an inserted row

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    11-30-2005
    Location
    Penzance Cornwall, UK
    MS-Off Ver
    Office 365
    Posts
    201

    VBA to highlight an inserted row

    Hi Guys

    Below is some code I am trying to complete but ot does not ALL work.

    I am inserting a row and I want the row to be highlighted.

    The insert part is working ok but not the highlight part.

    Can someone please help?


    With Workbooks("KeithSilver Dawn Income.xlsm").Sheets(Sheet_No)
                    rw = rw + 1
                    .Rows(rw).Insert
                    .EntireRow.Interior.ColorIndex = 27
                End With

    Cheers,
    Keith

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: VBA to highlight an inserted row

    Try this...

    With Workbooks("KeithSilver Dawn Income.xlsm").Sheets(Sheet_No)
        rw = rw + 1
        With .Rows(rw)
            .Insert
            .EntireRow.Interior.ColorIndex = 27
        End With
    End With


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Forum Contributor
    Join Date
    11-30-2005
    Location
    Penzance Cornwall, UK
    MS-Off Ver
    Office 365
    Posts
    201

    Re: VBA to highlight an inserted row

    Hi Sixthsense,

    Thank you for a very quick response and your suggestion.

    I copied & pasted the code and ran it, It probably did do what I asked for, but, unfortunately it didn’t do what I wanted.

    The code inserted the row in the correct place but then highlighted the row below the inserted row.

    I played round with the code after you enlightened me and came up with the code below that I now have working.

     With Workbooks("KeithSilver Dawn Income.xlsm").Sheets(Sheet_No)
                     rw = rw + 1
                            With .Rows(rw)
                               .Insert
                             End With
                      
                            With .Rows(rw)
                               .EntireRow.Interior.ColorIndex = 27
                            End With
                End With
    Thank you for you input.

    Keith

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 6
    Last Post: 06-21-2013, 10:45 PM
  2. vba to insert new row AND highlight NEWLY INSERTED ROW
    By wanty in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-01-2013, 11:56 PM
  3. Replies: 2
    Last Post: 06-27-2012, 12:27 PM
  4. [SOLVED] highlight/remove highlight of rows conditional on cellvalue
    By timtim89 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-01-2012, 07:14 AM
  5. Replies: 5
    Last Post: 05-27-2005, 02:05 PM

Tags for this Thread

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