?
SolvedPrivate

Seperate Data with VBA

Posted on 2015-02-10
4
Medium Priority
?
29 Views
Last Modified: 2016-02-10
I have an Excel 2010 file.  I want to be able to insert a blank row each time I see a value change.

Example:
DATE     VALUE
9/1/14      AB
9/2/14      AB
9/1/14      AC
9/8/14      AC

What I am wanting to do is separate the AB and AC data with a blank row with VBA.

So I would like to make my sheet look like this:

Example:
DATE     VALUE
9/1/14      AB
9/2/14      AB

9/1/14      AC
9/8/14      AC

Can you point me in the right direction to accomplish this?
Thanks.
0
Comment
Question by:gwlanks
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 12

Assisted Solution

by:James Elliott
James Elliott earned 1000 total points
ID: 40600827
Something like this should work.

Sub EE()

Dim i As Long

For i = Range("B" & Application.Rows.Count).End(xlUp).Row To 2 Step -1

    If Not Range("B" & i - 1).Value = Range("B" & i).Value Then Range("B" & i).Rows.Insert xlShiftDown
    
Next i

End Sub

Open in new window

0
 
LVL 12

Expert Comment

by:James Elliott
ID: 40600834
To implement:

(1) Hit Alt+F11 to open the VB Editor
(2) Double click the sheet on the left that contains your data
(3) Paste the code above on the right hand side
(4) Close the VB Editor
(5) Run the Macro
0
 
LVL 52

Accepted Solution

by:
Rgonzo1971 earned 1000 total points
ID: 40600862
Hi,

EDITED Code ' No blank row after first line and entirerow inserted
Sub EE()

Dim i As Long

For i = Range("B" & Application.Rows.Count).End(xlUp).Row To 3 Step -1

    If Not Range("B" & i - 1).Value = Range("B" & i).Value Then Range("B" & i).EntireRow.Insert xlShiftDown
    
Next i

End Sub

Open in new window

Regards
0
 

Author Closing Comment

by:gwlanks
ID: 40600894
After some tweaking on my side for the column it worked great.  Thank you very much for the fast response and your help is much appreciated.

Thanks,
Greg
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question