I have an excel sheet, from a dropdown list I will have numbers of items to select.
After selecting specific item, a specific macro is run that will paste vlookup formulas to the range of cells.
My workbook VBA looks as follows:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Select Case Range("B2")
Case "Company 1"
Call Company1
Case "Company 2"
Call Company2
End Select
End Sub
And my macros look as follows
Sub Company1()
Range("D7:D14").Formula = "=VLOOKUP(B7,'SheetLocation\[Sheet1.xls]Sheet1'!$A$6:$E$93,3,FALSE)"
End Sub
Sub Company2()
Range("D7:D14").Formula = "=VLOOKUP(B7,'SheetLocation\[Sheet2.xls]Sheet2'!$A$6:$E$93,3,FALSE)"
End Sub
With such macros everytime I select the value form dropdown list my excel hangs up with error Runtime error 28 - Out of stack space.
Need your help guys.
code
If Not Intersect(Target, Range("B2")) Is Nothing Then solved the issue. – Drcs