Consulting

Results 1 to 5 of 5

Thread: VBA To Insert A new Row with Specific formatting

  1. #1
    VBAX Mentor
    Joined
    Jan 2008
    Posts
    384
    Location

    VBA To Insert A new Row with Specific formatting

    I am trying to insert a new row into a worksheet, but after inserting the row,
    I want to change the new Row Interior.ColorIndex = 0 for Columns H to S only.
    I don't want to change the rest of the formatting.

    How do I code this so that I don't change the rest of that Row.
    This is how I'm inserting my new row.

    ActiveCell.Offset(1).EntireRow.Insert
    Last edited by Paul_Hossler; 07-24-2021 at 05:06 PM.

  2. #2
    VBAX Mentor
    Joined
    Nov 2020
    Location
    Cochin, Kerala
    Posts
    314
    Location
    may be
    Intersect(Rows(ActiveCell.Offset(1).Row), Range("H:S")).Interior.ColorIndex = 0

  3. #3
    VBAX Mentor
    Joined
    Jan 2008
    Posts
    384
    Location

    VBA To Inser A new Row with Specific formatting

    anish.ms: Thanks
    Unfortunately, that did not do the trick.
    The code had no effect on the new inserted Row.
    I will revisit it later.

  4. #4
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
        ActiveCell.Offset(1).EntireRow.Insert
        ActiveCell.Offset(1).EntireRow.Cells(1, 8).Resize(1, 12).Interior.ColorIndex = xlColorIndexNone
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  5. #5
    VBAX Mentor
    Joined
    Jan 2008
    Posts
    384
    Location
    Thanks Paul_Hossler:


    I did this clunky code to achieve the results that I was looking for once my brain got switched back on.


    ActiveCell.Offset(1).EntireRow.Insert
     Range("H" & ActiveCell.Offset(1, 0).Row & ":S" & ActiveCell.Offset(1, 0).Row).Interior.ColorIndex = 0
    I will try your code anyway.


    Thanks

Posting Permissions

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