Dòng tô màu xanh em bị báo lỗi, file em đánh lại giống video trên YouTube gitiho. Nhờ thầy hỗ trợ ạ
Chào bạn bạn đẩy file lên giúp gitiho nhé.
Hoặc dùng code sau
Sub link()
Dim link As Variant
link = Application.GetOpenFilename(FileFilter:="Pic Files (*.jpg;*.bmp;*png;*jpeg), *.jpg;*.bmp;*png;*jpeg", Title:="Select picture")
If link = False Then Exit Sub
Selection.value = link
Call chenanh
Call resizeanh
End Sub
Sub chenanh()
Dim rng As range
On Error Resume Next
For Each rng In Selection
ActiveSheet.Shapes(rng.Address).Delete
With ActiveSheet.Pictures.Insert(rng.value)
.name = rng.Address
ActiveSheet.Shapes((rng.Address)).LockAspectRatio = False
.Left = rng.Left: .Top = rng.Top
.width = rng.width: .Height = rng.Height
End With
Next
End Sub
Sub resizeanh()
Dim rng As range
On Error Resume Next
For Each rng In Selection
If rng.value <> "" Then
With ActiveSheet.Shapes((rng.Address))
.LockAspectRatio = False
.Left = rng.Left: .Top = rng.Top
.width = rng.width: .Height = rng.Height
End With
End If
Next
End Sub