SOLVED

I need help with this code

Copper Contributor

Hello

I have a vba script i need help with, the script function as is, but when i come to and image url what don´t exist then the script halt. I wish so i can add if image url is not valid jump to next and so on.

 

Sub InstallPictures()
    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual
    
    Dim url_column As Range
    Dim image_column As Range
    
    'column with url...
    Set url_column = Worksheets(1).UsedRange.Columns("A")
    'column where image will be inserted
    Set image_column = Worksheets(1).UsedRange.Columns("B")
    
    Dim i As Long
    For i = 2 To url_column.Cells.Count
        
    
      Set Picture = image_column.Worksheet.Pictures.Insert(url_column.Cells(i).Value)
        Picture.Left = image_column.Cells(i).Left
        Picture.Top = image_column.Cells(i).Top
        Picture.Height = 40
        image_column.Cells(i).EntireRow.RowHeight = 40
      
    
    Next
    
    Application.ScreenUpdating = True
    Application.Calculation = xlCalculationAutomatic
End Sub

 

Thanks in advance

LesBear

2 Replies
best response confirmed by LesBear (Copper Contributor)
Solution

@LesBear 

Place a line

    On Error Resume Next

above the loop

Thanks bud, that made the trick...
1 best response

Accepted Solutions
best response confirmed by LesBear (Copper Contributor)
Solution

@LesBear 

Place a line

    On Error Resume Next

above the loop

View solution in original post