Consulting

Results 1 to 3 of 3

Thread: Macro adds a row up without data

  1. #1
    VBAX Regular
    Joined
    Aug 2013
    Posts
    56
    Location

    Macro adds a row up without data

    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: testing.xlsx

    Cheers

  2. #2
    VBAX Contributor
    Joined
    Oct 2011
    Location
    Concord, California
    Posts
    101
    Location
    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.

  3. #3
    VBAX Regular
    Joined
    Aug 2013
    Posts
    56
    Location
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •