I'm trying to write a macro that combine the defined sheets from different workbooks and saves them to a separate workbook. Each workbook contains a sheet with the same name MODEL. This sheet has a combobox, this combobox is associated with the worksheet name like in code below:
Sub ComboBox1_Change()
Application.ScreenUpdating = False
Select Case Sheets("MODEL").Range("code_plant")
Case 1
Sheets("MODEL").Range("price_zero").Copy _
Destination:=Sheets("MODEL").Range("price_on_view")
End Select
Application.ScreenUpdating = True
End Sub
The problem arises when all the worksheets are combined together in one workbook and renamed. I need to fix my combobox macro that should after renaming refer to the current (renamed) sheet name. I was trying to use the following function but can't figure out how it may be include in my code in right way.
Function MySheet()
Application.Volatile
MySheet = Application.Caller.Worksheet.CodeName
End Function
Thanks!