+ Reply to Thread
Results 1 to 14 of 14

Insert Row under cell containing text on entire active sheet

  1. #1
    Registered User
    Join Date
    11-01-2013
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    7

    Insert Row under cell containing text on entire active sheet

    Morning folks I'm after some code that will search at the entire active sheet for the letter "x" appearing in cells and then automatically inserts a new row under the one that contains the x. This would have to happen on numerous instances throughout the active sheet.

    I'm a school teacher looking to make my life a little easier! Hope someone can help.

    Cheers.

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Insert Row under cell containing text on entire active sheet

    In which column would the "x" be appearing?
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    11-01-2013
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Insert Row under cell containing text on entire active sheet

    Could be in any column from C to U. CHeers.

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Insert Row under cell containing text on entire active sheet

    Do you have a sample file that you can upload?

    To Attach a File:

    1. Click on Go Advanced
    2. In the frame Attach Files you will see the button Manage Attachments
    3. Click the button.
    4. A new window will open titled Manage Attachments - Excel Forum.
    5. Click the Browse... button to locate your file for uploading.
    6. This will open a new window File Upload.
    7. Once you have located the file to upload click the Open button. This window will close.
    8. You are now back in the Manage Attachments - Excel Forum window.
    9. Click the Upload button and wait until the file has uploaded.
    10. Close the window and then click Submit.

  5. #5
    Registered User
    Join Date
    11-01-2013
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Insert Row under cell containing text on entire active sheet

    I attached the file.

    Thanks.
    Attached Files Attached Files

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Insert Row under cell containing text on entire active sheet

    In your example, there are x's in Unit 1. But there may or may not be x's in Unit 2 and 3. But since there is an "x" in Unit 1, an entire row has to be inserted right?

  7. #7
    Registered User
    Join Date
    11-01-2013
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Insert Row under cell containing text on entire active sheet

    yes thats correct.

  8. #8
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Insert Row under cell containing text on entire active sheet

    Are there chances of 2 or more x's in the same row?

    If yes, and if there is already a row inserted, then should the x be skipped?

  9. #9
    Registered User
    Join Date
    11-01-2013
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Insert Row under cell containing text on entire active sheet

    Yes, if there is an x already the others should be skipped. Sorry didnt realise how complicated this was going to be.

    Many thanks.

  10. #10
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Insert Row under cell containing text on entire active sheet

    See if this code works for you -
    Please Login or Register  to view this content.
    Copy the Excel VBA code
    Select the workbook in which you want to store the Excel VBA code
    Hold the Alt key, and press the F11 key, to open the Visual Basic Editor
    Choose Insert | Module
    Where the cursor is flashing, choose Edit | Paste

    To run the Excel VBA code:
    Choose Tools | Macro | Macros
    Select a macro in the list, and click the Run button

  11. #11
    Registered User
    Join Date
    11-01-2013
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Insert Row under cell containing text on entire active sheet

    I appreciate the time you've spent on this.

    I have done as you said and it displayed the "done" message at the end but did nothing to the spreadsheet. I put a few x's in different places to test too.

  12. #12
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Insert Row under cell containing text on entire active sheet

    Did you put the code in a module and in the same workbook containing the data?

    If there are "x"s in any cell and the corresponding cell below it is blank, then it wont insert a row.

  13. #13
    Registered User
    Join Date
    11-01-2013
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Insert Row under cell containing text on entire active sheet

    I see. Thats fantastic many thanks, you've saved me a lot of time and effort.

    Cant thank you enough!

  14. #14
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Insert Row under cell containing text on entire active sheet

    Based on your last post in this thread, its apparent that you are satisfied with the solution(s) you've received and have solved your question, but you haven't marked your thread as "SOLVED". I will do it for you this time.

    In future, to mark your thread as Solved, you can do the following -
    Select Thread Tools-> Mark thread as Solved.

    Incase your issue is not solved, you can undo it as follows -
    Select Thread Tools-> Mark thread as Unsolved.

    Also, since you are relatively new to the forum, i would like to inform you that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post which helped you. This adds to the reputation of the person who has taken the time to help you.

+ 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: 20
    Last Post: 01-11-2014, 05:39 AM
  2. [SOLVED] VBA codes to insert the rows and copy the first entire row text and insert sheet
    By PRADEEPB270 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-26-2013, 05:05 AM
  3. [SOLVED] Insert a piece of text to all active worksheets after the last cell with data in it
    By boomboomblock in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-15-2013, 07:22 AM
  4. If Cell=X then check for duplicates and insert entire rows in another sheet
    By shivark79 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-10-2012, 10:57 AM
  5. possible to write text in a label(active x) on a sheet instead of a cell?
    By gosa in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-05-2012, 06:28 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