Jaye Cavallo
New Member
- Joined
- Mar 10, 2022
- Messages
- 49
- Office Version
- 2016
- Platform
- Windows
I have been trying to insert a picture into a cell using VBA. I found this code on Google. I am using Excel 365. Can someone explain to me why I receive a syntax error with the following code?
Sub InsertImageIntoCell()
Dim imageURL As String
imageURL = "https://www.example.com/logo.png" ' Replace with your image URL
With ThisWorkbook.Worksheets("Sheet1") ' Change "Sheet1" to your desired sheet
.Range("A1").Value = "=IMAGE(""" & imageURL & "", 0)" ' Insert image in cell A1, fitting to cell
End With
End Sub
Sub InsertImageIntoCell()
Dim imageURL As String
imageURL = "https://www.example.com/logo.png" ' Replace with your image URL
With ThisWorkbook.Worksheets("Sheet1") ' Change "Sheet1" to your desired sheet
.Range("A1").Value = "=IMAGE(""" & imageURL & "", 0)" ' Insert image in cell A1, fitting to cell
End With
End Sub