Hello!
First post ever but I've been snooping for a while 
I created a macro that opens a worksheet generated from my work, and it pivots the data to a more user-friendly format. It works perfectly with what I want to do. However, I want to scale it for a much larger data set.
sub example()
Dim filename As String
Workbooks.Open filename
'Grabs data from source worksheet
Sheets("Call Report").Select
ActiveWorkbook.PivotChaches.Create(SourceType:=xlDatabase, SourceData:="Call Report!R1C1:R" & DynamicRangeVariable & "C24",_
Version:=xlPivotTableVersion14). '''code continues to create pivot
The issue I run into is that if the data is pulled from a large sample size, the raw data will be split into two worksheets named "Call Report" and "Call Report (2)".
How can I create an If/Else (or any other loop) statement where if only 1 sheet of source data is found, it will run the entire code I already built. However, if two sources are found, it will run a new code that consolidates multiple sheets to be able to create a single pivot.
I'd imagine it would be something like this but I don't know the VBA conditions for it. Please ignore the obvious syntax errors below. I just want to write out a map for what I hope will work.
If ("Call Report"==1 && "Call Report (2)"==0) Then
My code
Exit Sub
Else If ("Call Report"==1 && "Call Report (2)"==1) Then
New code to consolidate ranges
My code to create pivot from new range
Exit Sub
Else If CStr(filename)="False" Then
Exit Sub
' Is it even possible to have 2 Else If statements for 1 If like in java or c++?
Thanks!
Bookmarks