Check if a character is in a Word Table Cell

Hi,

I have a Word Table and I would like to check that if it has a "/" three characters from the right within a line of rows.

So information about the cell... I enter the following as a date (Not code, just type) "00/00", most of the time, this is all I have in the cell, but sometimes I my have some text and Line Feed.

I would like to add only the cells that have the date as above, so what I want to do is check that the cell is not empty ie first part of my code, but also check for the date (Both are needed to make this true).

I have this code, but it is giving me an error, but I just cannot spot the error...

     If Len(.Cell(WhichRow, 1).Range.Text) > 2 _
          And Mid(.Cell(WhichRow, 1).Range.Text, Right(.Cell(WhichRow, 1).Range.Text, 3), 1) <> "/" Then

               NoDate = NoDate + 1

     end if

If Cell is not Empty and if 3 from the right does not equal "/" then True.

Do I need to include the EndofCell so instead of 3 need 5.

Thank you for your help

Neil

Answer
Answer
Use Left(Right(oCell.Range, 5), 1)
Hope this helps,
Doug Robbins - MVP Office Apps & Services (Word)
dougrobbinsmvp@gmail.com
It's time to replace ‘Diversity, Equity & Inclusion’ with ‘Excellence, Opportunity & Civility’ - V Ramaswamy

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated October 1, 2021 Views 364 Applies to: