Consulting

Results 1 to 3 of 3

Thread: Reset MOST of Worksheet with Macro

  1. #1

    Reset MOST of Worksheet with Macro

    Hi All,

    I would like to add a button to a worksheet that will reset all cells to original state (empty, no highlighting, no bordering) with the exception of a few cells which I know in advance. Is there a relatively simple macro to do this?

  2. #2
    I sort of cheated. I did this:

    [VBA]Sub ClearSheet1()

    Dim rng

    Set rng = Sheet1.Range("a3:b20,e3:o100")
    rng.ClearContents
    rng.Interior.ColorIndex = 0
    Sheet1.Range("f3:g100").Borders.LineStyle = xlNone
    'NEED TO FIGURE OUT HOW TO WRITE THIS AS ("F3:G&"INTERPLENGTH")

    End Sub[/VBA]

    The obvious problem is how do I know what length G100 is really going to be. See comment in code...

  3. #3
    VBAX Expert Tinbendr's Avatar
    Joined
    Jun 2005
    Location
    North Central Mississippi (The Pines)
    Posts
    993
    Location
    [VBA]With Sheet1
    LastRow = .Cells(.Rows.Count, "G").End(xlUp).Row
    .Range("f3:g" & LastRow).Borders.LineStyle = xlNone
    End With
    [/VBA]

    David


Posting Permissions

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