I'm struggling to find the answers I need on this, hoping someone can help. I get the feeling the code i've written will need to be approached differently to achieve what I want to achieve.
I have produced some code that produces an IF statement on a cell and displays a corresponding description in another cell next to it, I have also added code to ensure it automatically updates if this value is changed. This works.
I now need to extend the code so it loops down the cells and repeats the same function. checking the IF statement and displaying the corresponding description in the respective cell next to it.
Sheet VBA:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Me.Range("A2:A10")) Is Nothing Then Exit Sub
Application.EnableEvents = False
On Error GoTo Finalise
Call Material_String
Finalize:
Application.EnableEvents = True
End Sub
Module:
Sub Material_String()
Dim MaterialOption As String
Dim MaterialDetail As String
MaterialOption = Range("A2").Value
If MaterialOption = "a" Then MaterialDetail = "a is bloody good"
If MaterialOption = "b" Then MaterialDetail = "b is excellent"
If MaterialOption = "c" Then MaterialDetail = "c is most good"
If MaterialOption = "d" Then MaterialDetail = "d is simply the best"
If MaterialOption = "e" Then MaterialDetail = "e's are just amazing"
Range("C2").Value = MaterialDetail
End Sub
Any pointers would be greatly appreciated.
Thanks
Matt
Aucun commentaire:
Enregistrer un commentaire