excel - 用文本“1”替换单元格中的图像
问题描述
我有一个 excel,每个单元格中有 1 列带有图片,该图片决定了某些内容,但我想将其更改为 1。只有 1 张图片,确切地说,该栏是 J;Name =PO history/release documentation 。有人可以帮我用VBA做吗 谢谢!
Public Sub Replace_Picture()
Const Replace_Text = "OK"
Dim shp as Shape
For Each shp In ActiveSheet.Shapes
If shp.TopLeftCell.Address = shp.BottomRightCell.Address Then
shp.TopLeftCell.Value = Replace_Text
shp.Delete
End If
Next
Set shp = Nothing
End Sub
我尝试了上面的代码,但它不起作用并且const replace_text
是红色的。我只想将那些带有图片的单元格更改为“1”,而那些空白将保持不变。
解决方案
我猜你想从 SAP 中删除 PO 历史形状。你可以试试下面的 VBA 代码。另一种方法是您可以直接从 SAP 中“复制+粘贴”数据,而不是“导出到 Excel”
Sub Replace_Shapes()
Dim Shp As Shape
Dim Shp_Address
For Each Shp In ActiveSheet.Shapes
If Shp.Type = msoPicture Then
'Identify the address of Shape by TopLeft
Shp_Address = Shp.TopLeftCell.Address
Range(Shp_Address) = 1
Shp.Delete
End If Next
End Sub
推荐阅读
- testing - How to wait for all actors to process their inboxes in a test
- tensorflow - 做预测时可以只运行一半的神经网络模型吗?
- linux - 如何在 Linux 中创建与静态链接位置无关的可执行 ELF?
- python - Python TypeError:找不到所需的参数'offset'(位置1)
- java - 字符串列表的最佳 Vaadin 组件
- spring-boot - 使用业务实体的自然 ID 作为主键
- postgresql - 在 postgres 中使用表标识的最后一个值重置标识列
- java - 如何修复“应用程序崩溃并在 mAuth = FirebaseAuth.getInstance(); 上出错”
- python - Pandas fillna() 不适用于 DataFrame 切片
- python - 我怎样才能进入这个类的角度?