Format Imported Reports

  • Thread starter Thread starter Dave R
  • Start date Start date
D

Dave R

We have reports imported from PC DMIS which are very long. Can someone give
me a macro to delete every 4th row up to R?......? Thank You!!!!
 
Hi,

The following code delete a row at every 4th line. To use it for any other
number of lines simply change the 4 in the first row of code to the number
you want.

To use it select a vacant range of cells in a single column corresponding to
the height of the range you want to insert blank rows iinto and run the
macro. Tools > Macro > Macros.

Sub InsertRows()
Selection = "=1/MOD(ROW(),4)"
Selection = Selection.Value
Selection.SpecialCells(xlCellTypeConstants, 16).EntireRow.Delete
Selection.EntireColumn.Delete
End Sub

This code runs extremely fast.

To add this code to a workbook:
1. Press Alt+F11 (opens the Visual Basic Editor)
2. Select your file in the Project - VBA Project window, top left (press
Ctrl+R if you do not see it.)
3. Choose Insert > Module
4. Copy the code above to the module on the right
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top