我需要以下
的帮助我vba要向下列b检查whcih单元格包含True然后为每个单元格包含真正的Dim文件路径,然后插入一个对象并在列N中显示为图标,其中列d为标签
任何帮助都会得到最多的赞赏
我试过了
Sub insert()
Dim rng As Range
Dim Ref As Boolean
Dim cell As Variant
Set rng = Range("b6:b76")
For Each cell In rng
Ref = cell.Value
If Ref = True Then
Dim path As String
path = ActiveCell.Offset(0, 1).Value
ActiveCell.Offset(0, 12).Select
ActiveSheet.OLEObjects.Add(Filename:=path _
, Link:=False, DisplayAsIcon _
:=True, IconFileName:= _
"C:\Windows\Installer\{AC76BA86-7AD7-1033-7B44-AA1000000001}\PDFFile_8.ico", _
IconIndex:=0, IconLabel:="Column d????"). _
Select
ActiveSheet.Shapes("Object 19").IncrementLeft 11.25
ActiveSheet.Shapes("Object 19").IncrementTop 36
Next
End Sub
答案 0 :(得分:0)
我现在尝试了这个,但在定义路径
时出错子插入()
Dim R As Integer
Dim path As String
对于R = 6到76
If Cells(R,2).Value =" True"然后
**Error Is Here** path = Cells(R, 3).Value
Cells(R, 12).Select
ActiveSheet.OLEObjects.Add(Filename:=path _
, Link:=False, DisplayAsIcon _
:=True, IconFileName:= _
"C:\Windows\Installer\{AC76BA86-7AD7-1033-7B44-AA1000000001}\PDFFile_8.ico", _
IconIndex:=0, IconLabel:="column d value ??"). _
Select
ActiveSheet.Shapes("Object 19").IncrementLeft 11.25
ActiveSheet.Shapes("Object 19").IncrementTop 36
End If
下一个R
End Sub