[英]How to check if an element exists in a column, and then insert a square with text in a certain cell
I have a macro which filters a list and copies the values filtered (isn't the important part), 我有一个宏,它过滤列表并复制过滤后的值(不是重要的部分),
From that list I need to check if certain values exist, for example "Gestión de dato maestro". 从该列表中,我需要检查是否存在某些值,例如“Gestiónde dato maestro”。 If this cell exists then I want to create a square in some cell with the text "Gestión de dato maestro".
如果存在该单元格,那么我想在某个单元格中创建一个带有文本“Gestiónde dato maestro”的正方形。
I tried using Vlookup in vba but it didnt work 我尝试在vba中使用Vlookup,但是没有用
List I want to work on 我要处理的清单
The output i need 我需要的输出
Try to use this, I'm using cell A20 of the same sheet of the list as my "input value to check" address, you can change it right there on Cells(20, 1)
尝试使用它,我将列表的同一张表格的单元格A20与我的“要检查的输入值”地址一起使用,您可以在
Cells(20, 1)
上立即对其进行更改
Sub createDataShapes()
Dim rng As Range
Dim shp, rect As Shape
Set rng = ThisWorkbook.ActiveSheet.Range("A1").CurrentRegion.Find(ThisWorkbook.ActiveSheet.Cells(20, 1).Value)
If Not IsNull(rng.Value) Then
For Each shp In ThisWorkbook.ActiveSheet.Shapes
shp.Delete
Next shp
ThisWorkbook.ActiveSheet.Shapes.AddShape msoShapeRectangle, 100, 100, 100, 100
Set rect = ThisWorkbook.ActiveSheet.Shapes(1)
rect.TextFrame.Characters.Text = rng.Value
End If
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.