I have a sheet with a macro that when i change a value in the cell E5, automatically fill certain fields in sheet1, searches and return values from a table on other sheet - sheetTable).
My goal now is to select a range of values in a column on sheetTable and assign each one of them to Cell E5 on sheet1, and print each one.
So let's say I select 3 cells with values: 45, 50 and 66. When I run the macro it will assign 45 to cell E5 and print sheet1, then it will assign 50 to cell E5 and print sheet1 and finally will assign 66 to cell E5 and print sheet1.
Private Sub Worksheet_Change(ByVal Target As Range) Dim KeyCells As Range Dim shape As Excel.shape ' The variable KeyCells contains the cells that will ' cause an alert when they are changed. Set KeyCells = Range("e5") If Not Application.Intersect(KeyCells, Range(Target.Address)) _ Is Nothing Then For Each shape In ActiveSheet.Shapes shape.Delete Next InsertPictureInRange Range("f2").Value & Range("e5").Value & ".jpg", _ Range("c9") InsertPictureInRange Range("f2").Value & Range("e5").Value & "_1.jpg", _ Range("i9") If Range("e5").Value = "" Then Exit Sub End If End Sub