Check if Table Cell value is equal to


"Excel VBA Help"

 


Play Friv Now - Play Friv Games
Go Back   The Code Cage Forums > Microsoft Topics > Microsoft Word Forum
Our Info Pages:-
The Code Cage - Microsoft Office help

Notices

Microsoft Word Forum Members, post questions in this forum if they are related to using Microsoft Word, this includes Document Properties, VBA Programming & Functionality etc.

New Reply
Thread Tools Rate Thread Display Modes
  #1  
Unread 26th February 2014, 11:51
sharky12345's Avatar
sharky12345 sharky12345 is offline
Junior Member
MS Office Version: MS Office 97, 2003, 2007,2010
MS Office Skill Level: Some VBA experience
 
Join Date: Oct 2013
Location: UK
Posts: 54
Posts Per Day: 0.04
My Top Tip Count: 0
Thanks to others: 0
Thanked 0 Times in 0 Posts
Reputation: 10 (4) sharky12345 is on a distinguished road
Default Check if Table Cell value is equal to
     Word: VBA   


------ Register to get rid of these "In Post" ads! ------

Category: Word: VBA   

Can someone help me understand why this doesn't work;

VBA CODE:
If ActiveDocument.Tables(1).Cell(42, 3).Range.Text = "New" Then 

I'm simply trying to test if the value of that cell is equal to the word "New", (which it is in this case), but the test is resulting in false.

The word "New" is the ONLY thing in that cell.

The Code Cage Advertisment
Advertisement
  #2  
Unread 26th February 2014, 12:54
RoyUK's Avatar
RoyUK RoyUK is offline
Administrator
Solution Centre Professional
MS Office Version: MS Office 2003, 2007, 2010
MS Office Skill Level: Proficient with MS Office
 
Join Date: Nov 2008
Location: Derbyshire, UK
Posts: 2,706
Posts Per Day: 0.87
My Top Tip Count: 4
Thanks to others: 2
Thanked 195 Times in 193 Posts
Reputation: 3320 (69) RoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond reputeRoyUK has a reputation beyond repute
4 Top Tips
England
Default Re: Check if Table Cell value is equal to

------ Register to get rid of these "In Post" ads! ------


Are there any hidden non-printing characters or spaces in the cell?
__________________
Hope that helps, RoyUK
For tips & examples visit free excel help
DatabaseForm
About me

  #3  
Unread 26th February 2014, 12:55
sharky12345's Avatar
sharky12345 sharky12345 is offline
Junior Member
MS Office Version: MS Office 97, 2003, 2007,2010
MS Office Skill Level: Some VBA experience
 
Join Date: Oct 2013
Location: UK
Posts: 54
Posts Per Day: 0.04
My Top Tip Count: 0
Thanks to others: 0
Thanked 0 Times in 0 Posts
Reputation: 10 (4) sharky12345 is on a distinguished road
Default Re: Check if Table Cell value is equal to

------ Register to get rid of these "In Post" ads! ------


No - completely empty

The Code Cage Advertisment
Advertisement
  #4  
Unread 4th March 2014, 08:17
macropod's Avatar
macropod macropod is offline
Solution Centre Professional
MS Office Version: MS Office 2000, 2003 & 2010
MS Office Skill Level: Proficient with MS Office
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 172
Posts Per Day: 0.07
My Top Tip Count: 0
Thanks to others: 0
Thanked 20 Times in 20 Posts
Reputation: 380 (11) macropod is just really nicemacropod is just really nicemacropod is just really nicemacropod is just really nice
Australia
Default Re: Check if Table Cell value is equal to

------ Register to get rid of these "In Post" ads! ------


You need to exclude the two characters that constitute the end-of-cell marker:
VBA CODE:
With ActiveDocument.Tables(1).Cell(42, 3).Range 
    If Left(.Text, Len(.Text) - 2) = "New" Then 
         '....
    End If 
End With 
__________________
Cheers,
Paul Edstein
[MS MVP - Word]

  #5  
Unread 4th March 2014, 08:20
sharky12345's Avatar
sharky12345 sharky12345 is offline
Junior Member
MS Office Version: MS Office 97, 2003, 2007,2010
MS Office Skill Level: Some VBA experience
 
Join Date: Oct 2013
Location: UK
Posts: 54
Posts Per Day: 0.04
My Top Tip Count: 0
Thanks to others: 0
Thanked 0 Times in 0 Posts
Reputation: 10 (4) sharky12345 is on a distinguished road
Default Re: Check if Table Cell value is equal to

------ Register to get rid of these "In Post" ads! ------


Thank you!

  #6  
Unread 4th March 2014, 09:21
Simon Lloyd's Avatar
Simon Lloyd Simon Lloyd is offline
Administrator
MS Office Version: MS Office 97 - 2013
MS Office Skill Level: Can use most of MS Office
 
Join Date: Aug 2008
Location: Manchester, England
Age: 52
Posts: 11,878
Posts Per Day: 3.73
My Top Tip Count: 11
Thanks to others: 48
Thanked 441 Times in 425 Posts
Reputation: 6660 (193) Simon Lloyd has a reputation beyond reputeSimon Lloyd has a reputation beyond reputeSimon Lloyd has a reputation beyond reputeSimon Lloyd has a reputation beyond reputeSimon Lloyd has a reputation beyond reputeSimon Lloyd has a reputation beyond reputeSimon Lloyd has a reputation beyond reputeSimon Lloyd has a reputation beyond reputeSimon Lloyd has a reputation beyond reputeSimon Lloyd has a reputation beyond reputeSimon Lloyd has a reputation beyond repute
11 Top Tips
Wales
Default Re: Check if Table Cell value is equal to

------ Register to get rid of these "In Post" ads! ------


How To Say Thanks!
How to say thanks!

Saying Thanks

If you have found a tip helpful then please click on the button (like the one on the left) to the bottom right of the post to register your appreciation. If you also found a particular post helpful click the green thumbs up button on that post too so others can quickly find a helpful post!

Saying thanks this way or marking as helpful ensures the person whose post you are marking gets reputation points



Glad we could be of help!
Help

Help

If your query has been solved please take a moment to let us and eveyone else know by either going to, Thread Tools > "Mark This Thread As Solved", shown by this iconMark Solved


or clicking the same icon and title in any of your posts within this thread :)


__________________
Regards,
Simon Lloyd
Microsoft Office Help

Want to say thanks? then hit this How to say thanks! button in any post you want to thank
If you find one of my posts helpful then hit this one Helpful Answer in the post that helped most!



The Code Cage Advertisment
Advertisement
New Reply
The Code Cage at Facebookhe Code Cage at Twitter


Tags
cell, check, equal, table

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

The Code Cage Affilliates



http://www.thecodecage.com/forumz tested by McAfee Security http://www.thecodecage.com/forumz tested by McAfee Security

All times are GMT +1. The time now is 18:00.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Template-Modifications by TMS
No part of this board, functionality or creatives may be copied or reproduced either in part or full without the express permission of The Code Cage Team.
Copyright ©2008 - , Simon lloyd.
We are not associated with nor employed by Microsoft in any way, we simply provide resources!
All MS office icons are registered trademarks of the application they represent and are used with permission from Microsoft
UA-8135493-1
Cultural Forum | Study at Malaysian University