![]() |
simple code with "abc" & "*"
Hi al,
I have this line of code: If Range(Cells(commentrij, 43), Cells(commentrij, 43)).Text = "abc" & "*" Then The cell contains abc followed by some other characters (depending on the row) but this line will not work. If I use the complete text of the content of the cell, e.g. "abcdef", the line of code works properly. I guess "abc" & "*" is incorrect, but I don't know why. What shoud it be? Thanks in advance for your help. Jack Sons The Netherlands |
simple code with "abc" & "*"
Wildcards don't work with this simple comparison.
You could use like: if range(...).text like "abc*" then or you could check the first 3 characters: if left(range(...).text, 3) = "abc" then ps. You don't need that .range(...) stuff--it's a single cell: if cells(commentrij,43).text like .... Jack Sons wrote: Hi al, I have this line of code: If Range(Cells(commentrij, 43), Cells(commentrij, 43)).Text = "abc" & "*" Then The cell contains abc followed by some other characters (depending on the row) but this line will not work. If I use the complete text of the content of the cell, e.g. "abcdef", the line of code works properly. I guess "abc" & "*" is incorrect, but I don't know why. What shoud it be? Thanks in advance for your help. Jack Sons The Netherlands -- Dave Peterson |
simple code with "abc" & "*"
Dave,
Response fast as lightning and very helpful, as always, thank you. Jack. "Dave Peterson" schreef in bericht ... Wildcards don't work with this simple comparison. You could use like: if range(...).text like "abc*" then or you could check the first 3 characters: if left(range(...).text, 3) = "abc" then ps. You don't need that .range(...) stuff--it's a single cell: if cells(commentrij,43).text like .... Jack Sons wrote: Hi al, I have this line of code: If Range(Cells(commentrij, 43), Cells(commentrij, 43)).Text = "abc" & "*" Then The cell contains abc followed by some other characters (depending on the row) but this line will not work. If I use the complete text of the content of the cell, e.g. "abcdef", the line of code works properly. I guess "abc" & "*" is incorrect, but I don't know why. What shoud it be? Thanks in advance for your help. Jack Sons The Netherlands -- Dave Peterson |
All times are GMT +1. The time now is 05:49 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com