snasui.com ยินดีต้อนรับ ยินดีต้อนรับสู่กระดานถามตอบ Excel and VBA และอื่น ๆ ที่เป็นมิตรกับทุกท่าน มีไฟล์แนบมหาศาล ช่วยให้ท่านค้นหาและติดตามศึกษาได้โดยง่าย สมาชิกท่านใดที่ยังไม่ได้ระบุ Version ของ Excel ที่ใช้งานจริง สามารถทำตาม Link นี้เพื่อจะได้รับคำตอบที่ตรงกับ Version ของท่านครับ ระบุ Version ของ Excel
Private Sub CommandButton1_Click()
Dim PicFormat As String
Dim Rng As Range
On Error Resume Next
PicList = Application.GetOpenFilename(PicFormat, MultiSelect:=True)
If IsArray(PicList) Then
xRowIndex = Application.ActiveCell.Row
xColIndex = Application.ActiveCell.Column
For lLoop = LBound(PicList) To UBound(PicList)
Set Rng = Cells(xRowIndex, xColIndex)
Set sShape = ActiveSheet.Shapes.AddPicture(PicList(lLoop), msoFalse, msoCTrue, Rng.Left, Rng.Top, Rng.Width, Rng.Height)
'xColIndex = xColIndex+1
xRowIndex = xRowIndex + 1
Next
End If
End Sub
You do not have the required permissions to view the files attached to this post.
Dim PicFormat As String
Dim Rng As Range
On Error Resume Next
PicList = Application.GetOpenFilename(PicFormat, MultiSelect:=True)
If IsArray(PicList) Then
For Each Rng In Selection
Set sShape = ActiveSheet.Shapes.AddPicture(PicList(lloop), _
msoFalse, msoCTrue, Rng.Left, Rng.Top, Rng.Width, Rng.Height)
lloop = lloop + 1
Next
Else
'Other Code
End If
For Each Rng In Selection
lloop = lloop + 1
Set sShape = ActiveSheet.Shapes.AddPicture(PicList(lloop), _
msoFalse, msoCTrue, Rng.Left, Rng.Top, Rng.Width, Rng.Height)
Next