I have the following VBA:
What it should be doing is if there is a value in B10 then I want a button named "I10" in cell I10. If there is a value in B11, I want a button called "I11" in cell I11 etc... and if a user deletes the cell in B11, then the button called I11 in cell I11 gets deleted. Right now though, it doesnt do anything at all.
Thanks in advance
Ben
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)Dim btn As Button
Dim t As Range
If Target.Address = "$B10:$B103" Then
If Target.Value <> "" Then
Set t = ActiveSheet.Range(Cells(i, 9), Cells(i, 9))
Set btn = ActiveSheet.Buttons.Add(t.Left, t.Top, t.Width, t.Height)
With btn
.OnAction = "imageshow"
.Caption = "View Images"
.Name = "I" & i
End With
Else
i = Target.Row
For Each btn In ActiveSheet.Buttons
If btn.Name = "I" & i Then
btn.Delete
End If
Next btn
End If
End If
End Sub
What it should be doing is if there is a value in B10 then I want a button named "I10" in cell I10. If there is a value in B11, I want a button called "I11" in cell I11 etc... and if a user deletes the cell in B11, then the button called I11 in cell I11 gets deleted. Right now though, it doesnt do anything at all.
Thanks in advance
Ben