Results 1 to 4 of 4
  1. #1
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Dallas, Texas, USA
    Posts
    1,680
    Thanks
    0
    Thanked 1 Time in 1 Post

    Macro to Delete Same Range - Many Sheets (XL2003)

    Hello,

    Trying to write a macro that will do two things...

    1. <LI>Delete Cell Contents in Range("B3:L98") on 31 sheets labeled "Day 1 Data" - "Day 31 Data" >> <font color=blue>Note: These sheets are actually Sheet3 - Sheet33. </font color=blue> <<
      <LI>And then leave Sheet1 as the active sheet, scrollbars all the way to the top left, and cell B7 as the active cell. >> <font color=blue>Note: The macro button is located on Sheet1, so it's already active, still need to make sure the screen is positioned to the top left (ex A1=visible) with B7 as the active cell.</font color=blue> <<
    So far, I've got:

    Sub Macro2()

    Sheets("Day 1 Data").Range("B3:L98").ClearContents
    Sheets("Day 2 Data").Range("B3:L98").ClearContents
    Sheets("Day 3 Data").Range("B3:L98").ClearContents
    Sheets("Day 4 Data").Range("B3:L98").ClearContents
    and on and on and on...

    Before I continue, I'm betting there's a more concise piece of code that will do this trick? And I haven't a clue what code to use to achieve the results noted in the 2nd bullet point above. <img src=/S/help.gif border=0 alt=help width=23 height=15>
    - Ricky

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Macro to Delete Same Range - Many Sheets (XL2003)

    As to your first question:

    Dim i As Integer
    For i = 1 To 31
    Worksheets("Day " & i & " Data").Range("B3:L98").ClearContents
    Next i

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Macro to Delete Same Range - Many Sheets (XL2003)

    As to #2:

    ActiveWindow.ScrollIntoView 0, 0, 1, 1
    Range("B7").Select

  4. #4
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Dallas, Texas, USA
    Posts
    1,680
    Thanks
    0
    Thanked 1 Time in 1 Post

    Thank You

    Incredible. Thanks
    - Ricky

Posting Permissions

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