+ Reply to Thread
Results 1 to 4 of 4

Not ignoring worksheets

Hybrid View

  1. #1
    Registered User
    Join Date
    08-12-2008
    Location
    BELLINGHAM
    Posts
    24

    Not ignoring worksheets

    Sub budgethistory()
    Dim myKey, myMessage, myTitle
    myMessage = "Which month are you entering? Enter month as a number."
    myTitle = "History"
    myKey = InputBox(myMessage, myTitle)
    
    Sheets("PivotData").Activate
        Range("ammountthisperiod").Select
        Selection.Copy
        
        monthnum = myKey
        
        Range("hist").Offset(0, monthnum - 1).Select
        Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
        False, Transpose:=False
        
    Dim Arr As Variant
    Dim i As Long
    Dim Wsht As Worksheet
    Arr = Array("E19", "E52", "E85", "E118", "E151", "E184", "E217", "E249")
    
    
    For Each Wsht In Worksheets
        Select Case UCase(Wsht.Name)
        Case "pivotdata", "sumtable"
         '
         Case Else
            For i = 0 To UBound(Arr)
                Wsht.Range(Arr(i)).ClearContents
            Next i
        End Select
    Next Wsht
        
    End Sub
    I have a problem with my code written above. this section:
        Select Case UCase(Wsht.Name)
        Case "pivotdata", "sumtable"
         '
    is not working and the array i have named is being deleted on this worksheet as well. i want to be able to input the worksheets ex. pivotdata, sumtable and have them be pardoned from the deleting. any thoughts?




    thanks

    -dillon

  2. #2
    Registered User
    Join Date
    08-12-2008
    Location
    BELLINGHAM
    Posts
    24
    Case "pivotdata", "sumtable"
    i tried changing this line to
    Case Wsht.pivotdata, Wsht.sumtable
    didnt work. also tried
    Case Sheets("pivotdata", "sumtable")
    didnt work. any suggestions to look into or anything. also i think that maybe the problem has to do with the case else as it is unbound, or would the sheets be ignored since they fit into the case section. lemme know your thought or suggestions on fixing this problem.


    ty in advance.

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    You are telling it to check for Upper Case, but using Lower Case. You don't need to loop through an array eitherr
    For Each Wsht In Worksheets
        Select Case UCase(Wsht.Name)
        Case "PIVOTDATA", "SUMTABLE"
         '
         Case Else
                Wsht.Range("E19, E52, E85, E118, E151, E184, E217, E249").ClearContents
        End Select
    Next Wsht
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    Registered User
    Join Date
    08-12-2008
    Location
    BELLINGHAM
    Posts
    24
    thank you very much for your help. i just changed them to uppercase because i dont understand the looping thing and its still working. thank you very much royuk

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Automatically format multiple worksheets
    By Kez in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-29-2008, 08:25 AM
  2. Deleting worksheets, printing to Adobe, and moving to a new workbook
    By baconcow in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-22-2008, 10:03 AM
  3. Export Access 97 to Excel on multiple worksheets extra sheets produced
    By syoung4 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-16-2007, 09:50 AM
  4. Replies: 8
    Last Post: 03-20-2007, 02:00 PM
  5. Multiple Inputs into other worksheets
    By mcwharam in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 01-08-2007, 05:57 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1