Solved

SPACE CREATION MACRO

Posted on 2014-02-20
3
194 Views
Last Modified: 2014-02-21
Reference the attached Excell file (spacingex.xlsx)

Would like to have a macro that creates 4 spaces after each DIFFERENT description listed.

Sheet 1 of the attached file has 7 different descriptions.
Other sheets that this macro can be applied will have anywhere from 2 to 15 different descriptions listed.

Sheet 1 of the attached file has the first description starting at cell location B5
Other sheets that this macro can be applied can have any starting point.

The cursor will be manually placed at the starting point, before the macro is run.

Sheet2 of the attached file shows the results of placing the cursor at B and then running the macro

MY system is Windows 8 and am running Excell 2013

                                                Tom
SPACINGEX.xlsx
0
Comment
Question by:radrick60
  • 2
3 Comments
 
LVL 59

Expert Comment

by:Saurabh Singh Teotia
ID: 39873008
Try this code..this will do what you are looking for...

Sub addspace()
Application.ScreenUpdating = False

    Dim lrow As Long, srow As Long
    Dim x As Long
    srow = 6    '<--- Your Starting Point

    Do Until srow > Cells(Cells.Rows.Count, "B").End(xlUp).Row

        If Cells(srow - 1, "b").Value = Cells(srow, "b").Value Then
            srow = srow + 1
        Else
           For x = 0 To 3
            Rows(srow + x).Insert
         Next x
            srow = srow + 5
        End If
    Loop

Application.ScreenUpdating = True
End Sub

Open in new window

0
 

Author Comment

by:radrick60
ID: 39873233
WORKED PERFECTLY!!

How do I make this macro available for all my current excell files and future files that i will create?
0
 
LVL 59

Accepted Solution

by:
Saurabh Singh Teotia earned 500 total points
ID: 39873330
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Drop Down List with Unique/Distinct Values (enhancing the Combo-Box with a few steps and a little code) David miller (dlmille) Intro Have you ever created a data validation list from a database field or spreadsheet column (e.g., Zip Codes or Co…
Dealing with unintended Excel Active-X resizing quirks (VBA code simulates "self correction") David Miller (dlmille) Intro Not everyone is a fan of Active-X controls in spreadsheets (as opposed to the UserForm approach, the older Form controls …
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

895 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now