How JustAnswer Works:

  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.

Ask Michael Hannigan Your Own Question

Michael Hannigan
Michael Hannigan, Office Specialist
Category: Microsoft Office
Satisfied Customers: 8294
Experience:  20+ Years Experience in Field. MCSE, ICCP, CNE, Greenbelt
23511658
Type Your Microsoft Office Question Here...
Michael Hannigan is online now
A new question is answered every 9 seconds

I have to add 3 blank rows, based on information in column

Customer Question

I have to add 3 blank rows, based on information in column 1 which is the order number.
All order numbers have different number of rows associated with them.
Example:

12
12
12
13
13
14
14
14
14
So I have to add 3 blank rows between orders when new order starts.
Thx.
Submitted: 1 year ago.
Category: Microsoft Office
Expert:  Russell H. replied 1 year ago.

Hi, thank you for contacting JustAnswer.com. My name is Russell. I will do my best to provide the right answer to your question.


Please tell me, in order that I may answer your question as appropriately as possible:

- What version of MS Excel (or is it MS Access?) you are asking about?

- Do you wish to add the blank rows manually.... or automatedly / automagically / etc. ?

Thanks.
Customer: replied 1 year ago.
2010 version. Automated. If row two minus row one is bigger than zero then add 3 rows.
Expert:  Russell H. replied 1 year ago.
I presume that your question regards XXXXX XXXXX which I do not know enough about to advise you on. So I have Opted Out, opening the case to other Experts in this category.
Expert:  Michael Hannigan replied 1 year ago.
Hello. My name is Michael. I will be providing an answer to your question today.

I have written a small piece of code that will accomplish what you want to do.

Just paste the following code in a macro for the sheet and it will insert 3 blank rows each time there is a change in column A.

Sub AddRows()
Dim myRow As Long
Dim myCount As Long
Dim myCol As Integer

myCol = 1
myCount = ActiveSheet.UsedRange.Rows.Count

For myRow = myCount - 1 To 1 Step -1
If Cells(myRow, myCol).Value <> Cells(myRow + 1, myCol).Value Then
Range(Cells(myRow + 1, myCol), Cells(myRow + 1, myCol)).EntireRow.Insert
Range(Cells(myRow + 1, myCol), Cells(myRow + 1, myCol)).EntireRow.Insert
Range(Cells(myRow + 1, myCol), Cells(myRow + 1, myCol)).EntireRow.Insert
Range(Cells(myRow + 1, myCol), Cells(myRow + 1, myCol)).Select
End If
Next myRow
End Sub

If your order numer is in a column other than A, just change the mycol value to the number of the column. For example, if it's in B, then set mycol to 2.

Let me know if you have any questions.
Expert:  Michael Hannigan replied 1 year ago.
Have you had time to test the macro? Please remember to rate my level of service. It's a very important part of the process and the only way I will receive credit for helping.

Mike
Customer: replied 1 year ago.


Please make response dummy proof.


 


I have to add 3 empty rows above a cell in colum A when the amount is bigger or small than zero (any number but zero).


 


A1 34


A2 18


A3 6


A4 0


A5 8


A6 0


A7 22


A8 13


A9 54


A10 0


 


As you see there is no consistancy in how many rows there are between the zeros.


 


Please write your response as if you were me writing this. Also I need to know if I need to modify if my next excel has more rows.


 


 


 

Expert:  Michael Hannigan replied 1 year ago.

In your original question, you said that you needed to add three rows inserted when the order number changes. And you gave the example of:

12
12
12
13
13
14
14
14
14

 

The macro that I gave you would result in:

12
12
12

 

 


13
13

 

 

14
14
14
14

 

Which is what I thought you were asking for. This sounds like an entirely different question.

 

You also mentioned "If row two minus row one is bigger than zero then add 3 rows", which I interpret to mean the same thing - if the order number changes, then insert 3 rows... except that you don't actually have to do a subtraction and then compare to 0 - you just have to compare it to the previous row and see if it's different. Are the zeroes in the new example some type of intermediate calculation?

 

I don't understand what the zeroes represent in your new example. Can you please clarify why it won't work to insert three rows when the number changes? That may help me understand what you are trying to do.

 

In the macro that I gave you, for an example, if there are 1000 rows, that represent 100 different orders, it will list items with the same order number until the order number change, then it will insert 3 rows before the next order number begins and it will do that for the entire worksheet.

 

Mike

JustAnswer in the News:

 
 
 
Ask-a-doc Web sites: If you've got a quick question, you can try to get an answer from sites that say they have various specialists on hand to give quick answers... Justanswer.com.
JustAnswer.com...has seen a spike since October in legal questions from readers about layoffs, unemployment and severance.
Web sites like justanswer.com/legal
...leave nothing to chance.
Traffic on JustAnswer rose 14 percent...and had nearly 400,000 page views in 30 days...inquiries related to stress, high blood pressure, drinking and heart pain jumped 33 percent.
Tory Johnson, GMA Workplace Contributor, discusses work-from-home jobs, such as JustAnswer in which verified Experts answer people’s questions.
I will tell you that...the things you have to go through to be an Expert are quite rigorous.
 
 
 

What Customers are Saying:

 
 
 
  • My Expert answered my question promptly and he resolved the issue totally. This is a great service. I am so glad I found it I will definitely use the service again if needed. One Happy Customer New York
< Last | Next >
  • My Expert answered my question promptly and he resolved the issue totally. This is a great service. I am so glad I found it I will definitely use the service again if needed. One Happy Customer New York
  • Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C. Freshfield, Liverpool, UK
  • This expert is wonderful. They truly know what they are talking about, and they actually care about you. They really helped put my nerves at ease. Thank you so much!!!! Alex Los Angeles, CA
  • Thank you for all your help. It is nice to know that this service is here for people like myself, who need answers fast and are not sure who to consult. GP Hesperia, CA
  • I couldn't be more satisfied! This is the site I will always come to when I need a second opinion. Justin Kernersville, NC
  • Just let me say that this encounter has been entirely professional and most helpful. I liked that I could ask additional questions and get answered in a very short turn around. Esther Woodstock, NY
  • Thank you so much for taking your time and knowledge to support my concerns. Not only did you answer my questions, you even took it a step further with replying with more pertinent information I needed to know. Robin Elkton, Maryland
 
 
 

Meet The Experts:

 
 
 
  • jstinehelfer

    Information Systems Manager

    Satisfied Customers:

    36
    A+ Comptia Certified computer repair
< Last | Next >
  • http://ww2.justanswer.com/uploads/JS/jstinehelfer/2012-6-6_215146_Pictureofme1.64x64.png jstinehelfer's Avatar

    jstinehelfer

    Information Systems Manager

    Satisfied Customers:

    36
    A+ Comptia Certified computer repair
  • http://ww2.justanswer.com/uploads/JA/JasonJames122/2011-12-16_135647_jasonjamesheadshotweb.64x64.jpg JasonJames122's Avatar

    JasonJames122

    Computer Enthusiast

    Satisfied Customers:

    0
    I manage all information systems (network of Windows PC's and servers with Microsoft Office products) for a small business
  • http://ww2.justanswer.com/uploads/JE/jessmagz/2012-6-6_18129_jm.64x64.jpg Jess M.'s Avatar

    Jess M.

    Computer Support Specialist

    Satisfied Customers:

    301
    Computer Software Specialist for more than 10 years
  • http://ww2.justanswer.com/uploads/CH/chutz747/2011-11-6_14231_me.64x64.jpg The-PC-Guy's Avatar

    The-PC-Guy

    Computer Manager

    Satisfied Customers:

    274
    20 years experience providing remote computer support
  • http://ww2.justanswer.com/uploads/SP/spherrod/2012-6-6_174244_1000852.64x64.JPG Steve Herrod's Avatar

    Steve Herrod

    Computer Support Specialist

    Satisfied Customers:

    125
    Trained in Microsoft Office from 2000 through to latest version 2010.
  • http://ww2.justanswer.com/uploads/SE/Seashore2011/2011-12-6_33418_111205223015.64x64.jpg Chris L.'s Avatar

    Chris L.

    Support Specialist

    Satisfied Customers:

    124
    Certified Expert with over 10 years experience.
  • http://ww2.justanswer.com/uploads/KR/krkljatorm/2012-6-24_153417_ITMiro.64x64.jpg IT Miro's Avatar

    IT Miro

    Computer Scientist

    Satisfied Customers:

    97
    Bachelor's Degree in Information Technology, Microsoft Certified Professional