PDA

View Full Version : Macro adds a row up without data



osevero
10-17-2013, 07:28 AM
Hello!

I'll need a macro that copies always row 7 (B7:G7) and adds a line up with the same formatting and formulas but no data in the cells. Example: 10724

Cheers

mrojas
10-17-2013, 07:58 AM
I'll assume that you already have a macro that copies the range.

Add to it the following steps:

Select range B:7-F7
Clear contents

Since those cells have literal values, they'll be cleared and their formatting kept, but the G7 cell, which has a formula, will remain intact.

osevero
10-17-2013, 09:18 AM
Well I used this code:


Sub add()
Rows("7:7").Insert Shift:=xlUp
Range("B8:G8").Copy
Range("B7").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Range("B7:F7").ClearContents
End Sub


I was trying some code better, but this one works fine