hey guys
i have a problem counting the number of characters in each cell in column "A" in a sheet and checking if number of characters in a cell exceeds 5 characters.
thanks in advance
regards
hey guys
i have a problem counting the number of characters in each cell in column "A" in a sheet and checking if number of characters in a cell exceeds 5 characters.
thanks in advance
regards
Last edited by mehdoush; 03-07-2009 at 09:41 AM.
Hello mehdoush,
Do you need a VBA solution for this? You can get the length of cell using the =LEN(A1) formula. This formula could be placed in another cell to perform the check.
Sincerely,
Leith Ross
Remember To Do the Following....
1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.2. Thank those who have helped you by clicking the Starbelow the post.
3. Please mark your post [SOLVED] if it has been answered satisfactorily.
Old Scottish Proverb...
Luathaid gu deanamh maille! (Rushing causes delays!)
Since this is the programming forum I hope this is the answer you're looking for:
![]()
If Len(Selection) > 5 Then 'insert your "do this next" code here
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
?None of us is as good as all of us? - Ray Kroc
?Actually, I *am* a rocket scientist.? - JB (little ones count!)
thank you guys
but in the code "selection" it should be replaced with the range which is column "A"
how can i modify this ?
regards
Hello mehdoush,
Can you provide a sample of this code? You still didn't answer the question of whether you need a VBA solution or not.
thnks Leith for ur interest
yes i do need vba
here's a sample of code :
here i need "selection" to be defined (cells in range A:A), you see![]()
Dim c As Range For Each c In Range("A:A") If Len(Selection) > 5 Then 'the code should highlight the cell where the exceed exists in red color Next c
regards
any help plz
![]()
Sub x() Dim cell As Range Range("A:A").Interior.ColorIndex = none For Each cell In Intersect(Columns("A"), ActiveSheet.UsedRange) If Len(cell.Text) > 5 Then cell.Interior.ColorIndex = 3 Next cell End Sub
Last edited by JBeaucaire; 04-08-2014 at 02:22 PM. Reason: Added a "reset" line of code in red so the macro can be run in succession and still work.
Entia non sunt multiplicanda sine necessitate
awesome shg
regards
how to change back the highlighted cell to no color after correct it?
Be careful, Mohonnah, it's against forum rules to post questions of your own in other people's threads, it is referred to as hijacking in the Forum Rules.
Since you may not have read the forum rules you agreed to, click on the link in the menu bar above and review them now to avoid problems later.
AS this question is very relevant to the reusability of the macro solution provided, I have added a line of code in red to SHG's original code above. This will reset all the coloring prior to highlighting the ones that are too long.
This thread is closed.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks