LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default If Then Else Pivot table

Where am I going wrong?

I am looking to have an If Then Else statement evaluate if cell A2 in a
specified tab is blank; if it is blank, the tab should be deleted, if it is
not, a pivot table based on the tab should be created in a new tab. Here is
the code that I have:

Sheets("Jan").Select
If Range("A2") < "" Then

Sheets.Add.Name = "JANP"

Dim wsdJANP As Worksheet
Dim ptcacheJANP As PivotCache
Dim ptJANP As PivotTable
Dim prangeJANP As Range
Dim finalrowJANP As Long
Set wsdJANP = Worksheets("Jan")

For Each ptJANP In wsd.PivotTables
ptJANP.TableRange2.Clear
Next ptJANP

finalrowJANP = wsdJANP.Cells(65536, 1).End(xlUp).Row
Set prangeJANP = wsdJANP.Cells(1, 1).Resize(finalrowJANP, 28)
Set ptcacheJANP = ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase,
SourceData:=prangeJANP.Address)
Set ptJANP =
ptcacheJANP.CreatePivotTable(tabledestination:=She ets("JANP").Range("A1"),
tablename:="PivotTable1")
pt.ManualUpdate = True

ptJANP.AddFields RowFields:=Array("ECPD_PROFILE_NM")
With ptJANP.PivotFields("ACTIVATIONS")
..Orientation = xlDataField
..Function = xlSum
..Position = 1

Else
Sheets("Jan").Delete
End If

When I attempt this code I get an error message that states "Compile Error:
Else without If"


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to create pivot table from existing pivot table in excel 2007 Udayraj Dhulekar Excel Discussion (Misc queries) 2 July 8th 13 08:22 PM
Filter lines with Pivot table and non pivot table columns Grover Charts and Charting in Excel 4 September 28th 07 03:16 AM
Filter lines with Pivot table and non Pivot table columns Grover Excel Discussion (Misc queries) 1 September 26th 07 12:48 AM
How do I create a pivot table if the pivot table icon or menu ite. Lynn@WS Charts and Charting in Excel 1 December 16th 04 02:36 AM
Help required with setting up a pivot table with the source on sheet1 to have the pivot table created on sheet called "report" Diana[_5_] Excel Programming 0 August 21st 03 10:19 PM


All times are GMT +1. The time now is 02:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"