简体   繁体   English

如何检查元素是否存在于列中,然后在特定单元格中插入带有文本的正方形

[英]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.

相关问题 如何检查单元格中的实际文本是否已经存在于Excel中的列中 - How to check if the actual text in the cell already exists in the column in excel 如何根据条件在excel的某个单元格中插入文本? - How to insert text in a certain cell in excel based on conditions? 检查文本或#是否在单元格中,如果并且仅存在,则添加该单元格和静态文本 - Check if text or # is in a cell, if and only it exists, add that cell and static text 检查整列以查看文本是否存在。 如果确实如此,则将其记录在其他单元格中 - Check an entire column to see if text exists. If it does then document it in a different cell 宏Excel:将文本插入圆形内的完美方形单元格 - Macro Excel: To insert a text into a perfect square cell within a circle shape 使用Excel VBA在单元格中的某些文本周围插入方括号 - Insert square brackets around some text in a cell using Excel VBA 如何检查“某个单元格中的一个”? 在Excel中 - How to check “a in a certain cell”? in excel 检查Column中是否存在Cell值,然后获取NEXT Cell的值 - Check if Cell value exists in Column, and then get the value of the NEXT Cell 如果单元格与列中的某个值匹配,则在相邻列中插入数据 - If cell matches a certain value in a column, insert data in an adjacent column VBA如何检查单元格值是否有效和存在? - VBA How to Check if Cell Value is valid and exists?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM