+ Reply to Thread
Results 1 to 4 of 4

Obvious Cells Not Found

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,955

    Obvious Cells Not Found

    I think this is best explained by the picture attached. In a nutshell, the code below is not finding my cells, thought they're obviously there. I tried replacing ".Value = "Stipend", with "Select" and the code still failed, but I don't understand why. Help would be highly appreciated.
    .Range("A2:A" & LastRow).SpecialCells(xlCellTypeVisible).Value = "Stipend"
    To be fair, I'll post the surrounding code in case there's something else that's messing it up.
    Private Sub CommandButton1_Click()
    'Have Excel get my Expenses
    
        Dim PT As PivotTable
        Dim PI As PivotItem
        Dim lCalc As XlCalculation
        Dim Wb As Workbook
        Dim WbSrc As Workbook
        Dim Ws As Worksheet
        Dim MFRmo As String
    
        With Application
            .ScreenUpdating = False
            .EnableEvents = False
            .DisplayAlerts = False
            lCalc = .Calculation
            .Calculation = xlCalculationManual
            .DisplayStatusBar = False
    
            Set Wb = ThisWorkbook
            Application.DisplayAlerts = False
            On Error Resume Next
            ThisWorkbook.Sheets("old_Current MFR").Delete
            ThisWorkbook.Sheets("Total Current Expense").Delete
            On Error GoTo 0
            Application.DisplayAlerts = True
    
            If IsEmpty(Wb.Sheets("Start Tab").Range("C2")) Then
                MsgBox "You first have to select a month on the Start Tab"
                Exit Sub
            End If
            If IsEmpty(Wb.Sheets("Start Tab").Range("C7")) Then
                MsgBox "You first have to select your name on the Start Tab"
                Exit Sub
            End If
    
    
            MFRmo = Wb.Sheets("Start Tab").Range("C2").Value
            Set Ws = Wb.Sheets(MFRmo & " MFR")
            Ws.Activate
    
    
            Ws.Name = "old_Current MFR"
            Ws.Visible = xlSheetHidden
    
            'FY15 code
            Set WbSrc = Workbooks.Open _
                        ("\\12aust1001fs01\SHARE10011\Budget\SOBUDGET\_Protected_Data\Source_Docs\_OOE_MOF_PivotTables\OOE_BR1415_ExpDtl_NonFCAdopt.xlsx", ReadOnly:=True, UpdateLinks:=True)
    
            Set PT = ActiveSheet.PivotTables("PivotTable1")
    
            With PT
                .ManualUpdate = True
    
                'FY15 code
                .PivotFields("BUDGET_REF").CurrentPage = "2015"
                .PivotFields("STRATEGY").Orientation = xlPageField
    
                With .PivotFields("BA")
                    .CurrentPage = Wb.Sheets("Start Tab").Range("C7").Value
                    .Orientation = xlPageField
                    .Position = 1
                End With
    
                On Error Resume Next
                With PT.PivotFields("FY_AP")
                    .Orientation = xlPageField
                    .Position = 1
                    For i = 1 To .PivotItems.Count
                        If .PivotItems(i).Name Like "*GOB*" Or .PivotItems(i).Name Like "*LAR*" Then
                            .PivotItems(i).Visible = False
                        Else
                            .PivotItems(i).Visible = True
                        End If
                    Next i
                End With
                On Error GoTo 0
    
                With PT.PivotFields("MOS2")
                    .Orientation = xlColumnField
                    .Position = 1
                    .PivotItems("BUDGET").Position = 1
                End With
    
                With PT.PivotFields("LBB_ACCT")
                    For Each PI In PT.PivotFields("LBB_ACCT").PivotItems
                        If PI = "FTEAFF" Or PI = "FTEATH" Or PI = "FTEHHSC" Or PI = "FTEABU" Or PI = "CP_Spread" Or PI = "L9999" Then
                            PI.Visible = False
                        Else
                            PI.Visible = True
                        End If
                    Next
                End With
    
                'Group the Funded FTEs together
    
                .ColumnGrand = False
                .RowGrand = False
                .RepeatAllLabels xlRepeatLabels
                .InGridDropZones = True
                .RowAxisLayout xlTabularRow
    
    
    
                '            With .TableRange1
                '                .Offset(2, 0).Resize(.Rows.Count - 2, .Columns.Count).Copy wsFTE.Range("B3")
                '            End With
    
                On Error Resume Next
                For Each PF In PT.PivotFields
                    'First, set index 1 (Automatic) to True,
                    'so all other values are set to False
                    PF.Subtotals(1) = True
                    PF.Subtotals(1) = False
                Next PF
                On Error GoTo 0
    
                'Let the PT update itself now
                .ManualUpdate = False
    
            End With
    
            'Convert my pivot to values
            PT.TableRange2.Select
            Selection.Copy
            With Selection
                .PasteSpecial xlPasteValuesAndNumberFormats
                .PasteSpecial xlPasteColumnWidths
            End With
            Application.CutCopyMode = False
            Set PT = Nothing
    
            'Move to our MFR Workbook.
            ActiveSheet.Move after:=Wb.Sheets("Aug MFR")
            ActiveSheet.Name = "Total Current Expense"
    
            With ActiveSheet
                'Determine our First row and delete what's above it
                LastRow = .Range("D1").End(xlDown).Row
                .Range("A1:Z" & LastRow).Delete
    
                'create our categories
                .Columns("C:C").Copy
                .Columns("A:A").Insert Shift:=xlToRight
                .Range("A1").Value = "Category"
    
                Dim RepWhat(), RepWith()
                RepWhat = Array("FTES", "FTEABF", "FTECAP", "L2005B", "L2005", "L2005M", "L1002", "L1001O", "L1001")
                RepWith = Array("Filled/Projected", "Funded FTEs", "Funded FTEs", "L2005B-Out of State Travel", "L2005-In State Travel", "L2005M-In State Mileage", "Other Personnel", "Overtime", "Salary")
    
                For i = LBound(RepWhat) To UBound(RepWhat)
                    .Columns("A").Replace What:=RepWhat(i), Replacement:=RepWith(i), _
                                          LookAt:=xlPart, SearchOrder:=xlByRows
                Next i
         Stop
                'Isolate our Stipend
                .Range("A1").AutoFilter Field:=3, Criteria1:="=11003"
                .Range("A1").AutoFilter Field:=4, Criteria1:="=L2009"
                .Range("A2:A" & LastRow).SpecialCells(xlCellTypeVisible).Value = "Stipend"
                .AutoFilterMode = False
    
    
                'insert a column for Type
                .Columns(1).Insert
                .Range("A1").Value = "Cost Per?"
                .Range("A2:A" & LastRow).FormulaR1C1 = "=IF(LEFT(RC[1],1) = ""L"",""Lbb Acct"",""Cost Per"")"
    
                'insert a column for Lookup
                .Columns(1).Insert
                .Range("A1").Value = "Lookup"
                .Range("A2:A" & LastRow).FormulaR1C1 = "=RC[1]&RC[2]&RC[3]&RC[4]&RC[5]"
    
                .Columns.AutoFit
    
            End With
    
            'Copy it and make it our MFR Projection template
            ActiveSheet.Copy after:=Sheets("Start Tab")
            Set Ws = ActiveSheet
            Ws.Name = MFRmo & " MFR"
    
            'Now let's start slicing and dicing
    
    
            'Determine our ranges for Expense (include the MFR month), Projections, Budget
            Range("AX1:AX25").Name = "RMEX_DET"
    
            .DisplayStatusBar = True
            .EnableEvents = True
            .Calculation = lCalc
            .ScreenUpdating = True
        End With
    
    
    End Sub
    Attached Images Attached Images

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Obvious Cells Not Found

    Are you sure the code is looking at the right worksheet in the right workbook?
    If posting code please use code tags, see here.

  3. #3
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,955

    Re: Obvious Cells Not Found

    Yep. It's got me stumped. Everything works like a champ until I get to that line.

  4. #4
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,955

    Re: Obvious Cells Not Found

    Sometimes my obtuseness astounds me. I hadn't told it what my new Last Row was. Sorry to waste everybody's time.

+ 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. Making a drop down more obvious
    By kosciosco in forum Excel General
    Replies: 1
    Last Post: 04-28-2014, 06:07 AM
  2. Making Track changes more obvious
    By asparak in forum Excel General
    Replies: 0
    Last Post: 07-12-2012, 03:23 AM
  3. Massive File Size for No Obvious Reason...
    By chconnol in forum Excel General
    Replies: 5
    Last Post: 01-21-2012, 12:45 PM
  4. Must Be Missing Something Obvious About ListBoxes
    By Johnny Meredith in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-04-2005, 04:05 AM
  5. Not so obvious Chart?
    By rvExcelNewTip in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 06-01-2005, 01:05 PM

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