Closed Thread
Results 1 to 5 of 5

How to insert blank row above a cell containing specific text

Hybrid View

  1. #1
    Registered User
    Join Date
    01-28-2014
    Location
    Dunedin, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    50

    How to insert blank row above a cell containing specific text

    Hi everyone

    Can someone assist me with using VB to insert a new row above a cell containing the word "Asset"?

    I've attached a copy of my spreadsheet if that helps!


    Thanks
    Emma
    Attached Files Attached Files

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2406 Win 11 Home 64 Bit
    Posts
    23,982

    Re: How to insert blank row above a cell containing specific text

    Emma

    Try this:

    Option Explicit
    
    Sub emma()
    Dim lr As Long
    lr = Range("A" & Rows.Count).End(xlUp).Row
    Dim i As Long
    
    Application.ScreenUpdating = False
    
    For i = lr To 5 Step -1
    If Range("A" & i).Value Like "Asset*" Then
    Range("A" & i).EntireRow.Insert
    End If
    Next i
    Application.ScreenUpdating = True
    MsgBox ("complete")
    
    End Sub
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    01-28-2014
    Location
    Dunedin, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: How to insert blank row above a cell containing specific text

    Hi - sorry, thought I'd replied but obviously mucked up somewhere! Solution is perfect, thanks so much for your help

  4. #4
    Forum Contributor
    Join Date
    02-18-2013
    Location
    Berlin, Germany
    MS-Off Ver
    Excel 2016
    Posts
    221

    Re: How to insert blank row above a cell containing specific text

    One question: This code inserts a row with formatting. If you want a completely blank row without formatting, how would you change the code?

  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2406 Win 11 Home 64 Bit
    Posts
    23,982

    Re: How to insert blank row above a cell containing specific text

    @excelactuary

    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original. Please start a new thread - See Forum rule #4

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 3
    Last Post: 07-12-2013, 09:17 AM
  2. [SOLVED] Macro - insert blank row below cell containing specific value
    By haleakala17 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-17-2013, 10:21 AM
  3. Deleting rows if specific cell is blank or have specific text
    By JoaoFerreira1985 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-11-2013, 01:18 PM
  4. [SOLVED] If the specific letter exists insert blank cell to the right
    By djfscouse in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-29-2012, 05:56 PM
  5. How to insert blank row below a cell containing specific text
    By Lmsloman in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 05-15-2012, 02:59 AM

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