I'm using this code to add photos based on folder image name and this worked fine but i want to insert image to more than 1 columns. There is any ways to do it? Hope you guys can help me. For example my picname value on columns A; C; E and my pic pasthere value on columns B; D; F ... how can i do it?
VBA Code:
Sub InsertAllPicture()
Dim pictname As String
Dim pastehere As Range
Dim pasterow As Long
Dim x As Long
Dim lastrow As Long, cPic
lastrow = Worksheets("sheet1").Range("A3").CurrentRegion.Rows.Count
x = 3
For x = 3 To lastrow
Set pastehere = Cells(x, 6)
pasterow = pastehere.Row
Cells(pasterow, 6).Select 'This is where picture will be inserted
pictname = Cells(x, 5) 'This is the picture name
Set cPic = ActiveSheet.Shapes.AddPicture("D:\O 3\SAM PHAM BAN\PRODUCTS POST\Product Insert PR SKU\" & pictname & ".jpg", False, True, PosizLeft, PositTop, True, True)
With cPic
.LockAspectRatio = msoFalse
.Height = 80#
.Width = 80#
.Left = Cells(pasterow, 6).Left + Cells(pasterow, 1).Width / 2 - .Width/2
.Top = Cells(pasterow, 6).Top + Cells(pasterow, 1).Height / 2 - .Height/2
End With
Next x
Set cPic = Nothing
End Sub