Hi I have 2 workbooks from 2 months of sales (see attachment) I would like to identify those opportunities that have moved from one sales stage to another. If sample 0 is last month and sample 1 is this month, how can I identify those opportunities that have changed sales stage but only up until the developing stage???
The data is found in each workbook in a sheet called data
The Sales Stage Name is column F of each data sheet
Opportunities are distinguised by their Opportunity ID, column L
I would like to list the opportunities that have changed from one stage to another in the past month (thus comparing workbook sample 0 to workbook sample 1) and list them in this month's (sample 1) workbook on the sheet named developping opportunities.
Remember only up to the develop stage (thus 2 scenarios possible...(1) Prospect 0% to Qualify 10% or (2) Qualify 10% to Develop 20%. Thank you
Change in data; comparing 2 workbooks
-
-
Re: Change in data; comparing 2 workbooks
This works okay for me, let me know your results.
Code
Display MoreSub Kallia() 'Written by Barrie Davidson Dim FileToOpen As Variant Dim LastMonth As Workbook Dim LookupRange As Range Dim Comparison As Range Application.ScreenUpdating = False FileToOpen = Application.GetOpenFilename("Excel files (*.xls),*.xls", , "Select last month's file") If FileToOpen = False Then Exit Sub With Sheets("Data") Set Comparison = .Range("M2:M" & .Range("L65536").End(xlUp).Row) End With Workbooks.Open FileToOpen Set LastMonth = ActiveWorkbook With Sheets("Data") Set LookupRange = .Range("L2:L" & .Range("L65536").End(xlUp).Row) End With Comparison.Formula = "=INDEX([" & LastMonth.Name & _ "]Data!" & LookupRange.Offset(, -6).Address & ",MATCH(L2,[" & _ LastMonth.Name & "]Data!" & LookupRange.Address & ",0))" Comparison.Value = Comparison.Value Comparison.TextToColumns DataType:=xlDelimited, _ TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=False, _ Semicolon:=False, Comma:=False, Space:=True, Other:=False, FieldInfo _ :=Array(Array(1, 9), Array(2, 1)) LastMonth.Close False Comparison.Offset(, 1).Value = Comparison.Offset(, -7).Value Comparison.Offset(, 1).TextToColumns DataType:=xlDelimited, _ TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=False, _ Semicolon:=False, Comma:=False, Space:=True, Other:=False, FieldInfo _ :=Array(Array(1, 9), Array(2, 1)) Comparison.Offset(, 2).Formula = "=IF(AND(N2-M2>0,N2<=0.2),TRUE,FALSE)" Comparison.Offset(-1, -12).Resize(Comparison.Rows.Count + 1, 15). _ AutoFilter Field:=15, Criteria1:="TRUE" Comparison.Offset(-1, -12).Resize(Comparison.Rows.Count + 1, 12). _ SpecialCells(xlCellTypeVisible).Copy _ Destination:=Sheets("Developping Opportunities ").Range("A1") Comparison.Offset(, -12).Resize(, 15).AutoFilter Comparison.Resize(, 3).ClearContents Application.ScreenUpdating = True End Sub
-
Re: Change in data; comparing 2 workbooks
Hey so I modified the formula to fit my workbooks. This Month's Workbook is named 'July 4th,2005 GTM Report', and last month's is named '2005-09-06GTM Report'. The data sheet is actually called 'OPTY fActMgr gGTM Excel'. (I also changed the range to L500 because I have formulas on that sheet starting at 501). When I try to run the macro it says that there is an error. When I try to debug, it tells me that the error is the "orange writting". I have not changed that part of the macro...Any clue as to why this is happening?
Sub Developing_Opts()
'Written by Barrie Davidson
Dim FileToOpen As Variant
Dim LastMonth As Workbook
Dim LookupRange As Range
Dim Comparison As Range
Application.ScreenUpdating = False
FileToOpen = Application.GetOpenFilename("Excel files (*.xls),*.xls", , "2005-09-06GTM Report")
If FileToOpen = False Then Exit Sub
With Sheets("OPTY fActMgr gGTM Excel")
Set Comparison = .Range("M2:M" & .Range("L500").End(xlUp).Row)
End With
Workbooks.Open FileToOpen
Set LastMonth = ActiveWorkbook
With Sheets("OPTY fActMgr gGTM Excel")
Set LookupRange = .Range("L2:L" & .Range("L500").End(xlUp).Row)
End With
Comparison.Formula = "=INDEX([" & LastMonth.Name & _
"]OPTY fActMgr gGTM Excel!" & LookupRange.Offset(, -6).Address & ",MATCH(L2,[" & _
LastMonth.Name & "]OPTY fActMgr gGTM Excel!" & LookupRange.Address & ",0))" Comparison.Value = Comparison.Value
Comparison.TextToColumns DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=False, _
Semicolon:=False, Comma:=False, Space:=True, Other:=False, FieldInfo _
:=Array(Array(1, 9), Array(2, 1))
LastMonth.Close False
Comparison.Offset(, 1).Value = Comparison.Offset(, -7).Value
Comparison.Offset(, 1).TextToColumns DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=False, _
Semicolon:=False, Comma:=False, Space:=True, Other:=False, FieldInfo _
:=Array(Array(1, 9), Array(2, 1))
Comparison.Offset(, 2).Formula = "=IF(AND(N2-M2>0,N2<=0.2),TRUE,FALSE)"
Comparison.Offset(-1, -12).Resize(Comparison.Rows.Count + 1, 15). _
AutoFilter Field:=15, Criteria1:="TRUE"
Comparison.Offset(-1, -12).Resize(Comparison.Rows.Count + 1, 12). _
SpecialCells(xlCellTypeVisible).Copy _
Destination:=Sheets("Developing Opportunities ").Range("A1")
Comparison.Offset(, -12).Resize(, 15).AutoFilter
Comparison.Resize(, 3).ClearContents
Application.ScreenUpdating = True
End Sub -
Re: Change in data; comparing 2 workbooks
That should be four lines not 3. Make sure it's
CodeComparison.Formula = "=INDEX([" & LastMonth.Name & _ "]OPTY fActMgr gGTM Excel!" & LookupRange.Offset(, -6).Address & ",MATCH(L2,[" & _ LastMonth.Name & "]OPTY fActMgr gGTM Excel!" & LookupRange.Address & ",0))" Comparison.Value = Comparison.Value
and not
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!