VBAnoob_Corina
New Member
- Joined
- Apr 17, 2014
- Messages
- 13
Hello everybody,
hope you can help me with the following problem: I'm trying to compare some cell entries from a worksheet to some shape text on another sheet. I have written some code already, but I get nothing but errors no matter what I try. The cell entries are located in "Lists", in the columns D-G and each amount of entries may vary. My shapes are plain rounded rectangles located in "Checklist Structure". I need this comparison as a condition for some further code which generates and places new shapes for entries not matching any shape text. I hope you can somehow understand what I'm trying to achieve I'm also very grateful for any help I can get. Thank you very much for the support!
Kind regards,
VBAnoob_Corina (The name says it all )
hope you can help me with the following problem: I'm trying to compare some cell entries from a worksheet to some shape text on another sheet. I have written some code already, but I get nothing but errors no matter what I try. The cell entries are located in "Lists", in the columns D-G and each amount of entries may vary. My shapes are plain rounded rectangles located in "Checklist Structure". I need this comparison as a condition for some further code which generates and places new shapes for entries not matching any shape text. I hope you can somehow understand what I'm trying to achieve I'm also very grateful for any help I can get. Thank you very much for the support!
Kind regards,
VBAnoob_Corina (The name says it all )
Code:
Option Explicit
Sub CreateShapes()
Dim ws As Worksheet
Dim SrchRng
Dim shp As Excel.Shape
Dim myText As Variant
Dim c As Range
Dim cellEntry As Variant
Dim lastRow
On Error GoTo ErrHandler
Set ws = Worksheets("Lists")
Set shp = Worksheets("Checklist Structure").Shapes(1)
lastRow = ws.Cells(Rows.count, 1).End(xlUp).row
Set SrchRng = ws.Range("D3:P" & lastRow)
myText = shp.TextFrame2.TextRange.Characters.Text
cellEntry = SrchRng.Cells.Value
With ws
For Each cellEntry In SrchRng
If cellEntry <> "" Then 'If cell is not blank then compare entry with each shape text
Set c = SrchRng.Find(cellEntry, LookIn:=myText)
If Not c Is Nothing Then 'do nothing
Else
MsgBox ("Bisher klappts!")
End If
Else 'do nothing
End If
Next cellEntry
End With
ErrHandler:
Call MsgBox(Err.Description, vbCritical, "Error " & Err.number)
End Sub