sparky2205
Well-known Member
- Joined
- Feb 6, 2013
- Messages
- 507
- Office Version
- 365
- 2016
- Platform
- Windows
Hi folks,
I have a small piece of code that changes the text of a button depending on what is selected from a drop down list.
The drop down list is on a worksheet called Tabelle2
Both the INDEX range and the MATCH range are on a worksheet called Languages
The code below works fine but I want to change it to...
k = Application.Index(Sheets("Languages").Range(Button), Application.Match(i, Sheets("Languages").Range(Index), 0))
...as the ranges are dynamic.
But this throws the "Application-defined or object-defined error"
Maybe I'm not referencing these ranges correctly?
I have a small piece of code that changes the text of a button depending on what is selected from a drop down list.
The drop down list is on a worksheet called Tabelle2
Both the INDEX range and the MATCH range are on a worksheet called Languages
The code below works fine but I want to change it to...
k = Application.Index(Sheets("Languages").Range(Button), Application.Match(i, Sheets("Languages").Range(Index), 0))
...as the ranges are dynamic.
But this throws the "Application-defined or object-defined error"
Maybe I'm not referencing these ranges correctly?
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Integer
Dim k As String
i = ActiveSheet.Range("D1").Value
k = Application.Index(Sheets("Languages").Range("B2:B4"), Application.Match(i, Sheets("Languages").Range("A2:A4"), 0))
ActiveSheet.Shapes("Button 1").TextFrame.Characters.TEXT = k
End Sub