Thread: [Solved] VBA IF Statement Help
View Single Post
 
Old 03-19-2024, 01:26 AM
Shelley Lou Shelley Lou is offline Windows 10 Office 2016
Competent Performer
 
Join Date: Dec 2020
Posts: 173
Shelley Lou is on a distinguished road
Default VBA IF Statement Help

Hi Greg, quite simply WOW, this is simply amazing, thank you so much for spending the time on creating this, it would take me a lifetime to come up with something like this, really can't thank you enough.

I can see its those pesky non breaking spaces causing trouble again, I will have to test further with ^s, although strangely it works ok for 'and'.

Just so I can understand the code a bit better, the 'and' part of the code below seems to have two "d" ranges and I wondered why that was.

Code:
 Case oRng.Characters.Last.text = " " And oRng.Characters.Last.Next.text = "a" And oRng.Characters.Last.Next.Next.text = "n" And oRng.Characters.Last.Next.Next.Next.text = "d" And oRng.Characters.Last.Next.Next.Next.text = "d"
oRng.Move wdCharacter, 5 'Seperated by the word 'and'
              lngOffset = 5
Am I on the right track with this line of code for the 'and/or' - its not working yet but if you say I'm on the right track I have something to work with.

Code:
Case oRng.Characters.Last.text = " " And oRng.Characters.Last.Next.text = "a" And oRng.Characters.Last.Next.Next.text = "n" And oRng.Characters.Last.Next.Next.Next.text = "d" And oRng.Characters.Last.Next.Next.Next.Next.text = "/" _
And oRng.Characters.Last.Next.Next.Next.Next.Next.text = "o" And oRng.Characters.Last.Next.Next.Next.Next.Next.Next.text = "r" And oRng.Characters.Last.Next.Next.Next.Next.Next.Next.Next.text = " "
oRng.Move wdCharacter, 8
lngOffset = 8
Reply With Quote