+ Reply to Thread
Results 1 to 6 of 6

Automatically insert a blank row below each row that has a value in a certain column

  1. #1
    Registered User
    Join Date
    06-25-2012
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    13

    Automatically insert a blank row below each row that has a value in a certain column

    After importing a data set into the worksheet entitled "SPACE", I am trying to find the column entitled "Variability Cpu" and then for every cell in that column that has a value in it, I would like to insert a new row beneath that cell. I thought my code made sense, but I get the "Run-time error '424': Object required" error on the line in red below so apparently I'm missing something. I would greatly appreciate a push in the right direction and an explanation of why I'm getting this error (doesn't the object variable shtS refer to the worksheet object "SPACE"? Why is it saying object required?). Here's what I've got so far:

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Automatically insert a blank row below each row that has a value in a certain column

    Improved code

    Please Login or Register  to view this content.
    Last edited by AB33; 07-28-2014 at 02:03 PM.

  3. #3
    Registered User
    Join Date
    06-25-2012
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Automatically insert a blank row below each row that has a value in a certain column

    Thanks AB33, but your suggested code inserts exactly rwS/2 (which in this case equals 113) blank rows above the first row in the spreadsheet all at once, instead of just one blank row beneath each cell in the "Variability Cpu" column that has a value. Can you help me understand why my code doesn't work? It seems like it should to me, but then again I'm fairly new to VBA.

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Automatically insert a blank row below each row that has a value in a certain column

    First,
    Please Login or Register  to view this content.
    Is not right if the code is unable to find "Variability Cpu"

    Please Login or Register  to view this content.
    is wrong, you can only do that on the above line which is a range.
    If you could attach a sample and desired output, I will adjust the code

  5. #5
    Registered User
    Join Date
    02-08-2013
    Location
    Louisiana, USA
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: Automatically insert a blank row below each row that has a value in a certain column

    I tried to use your code but was having problems with the loop section for rw = 2 to rws. Inside your loop you have a line of code
    Please Login or Register  to view this content.
    This line of code works if you insert an equals sign between the Value and then combine the IsNothing into one word, but it doesn't properly account for moving the active cell over newly inserted rows.

    I made some changes to the code. The two assumptions that I made are some column will have a heading named "Variability Cpu" and you are using column A to determine how
    many times to run your loop.

    I hope this works for you!

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    06-25-2012
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Automatically insert a blank row below each row that has a value in a certain column

    Thanks bstier! Your assumptions were correct and your code worked great, I just had to change "ActiveCell.Value = IsNothing" to "ActiveCell.Value = 0", since it treated "IsNothing" as an undefined variable.

+ 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. Automatically Insert a blank row
    By joebell in forum Excel General
    Replies: 1
    Last Post: 11-11-2012, 08:38 AM
  2. Replies: 3
    Last Post: 06-25-2009, 05:43 AM
  3. [SOLVED] How do I automatically insert a blank row between sets of data?
    By usdivers in forum Excel General
    Replies: 3
    Last Post: 08-17-2006, 08:30 PM
  4. [SOLVED] automatically insert 8 blank rows between each record
    By Evad in forum Excel General
    Replies: 1
    Last Post: 02-02-2006, 12:40 AM
  5. [SOLVED] how do I insert a blank row when a value changes, automatically
    By mb5451 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-11-2005, 11:15 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