I am using the below code and getting an error when I add in the "or" statement to the If cells <> Weight or Letter then multiply the cells by 1.
Where am I going wrong on this??
Please Login or Register to view this content.
I am using the below code and getting an error when I add in the "or" statement to the If cells <> Weight or Letter then multiply the cells by 1.
Where am I going wrong on this??
Please Login or Register to view this content.
Try
Cell.Text <> "Letter"
or
Cell.Value <> "Letter"
I really think your logic is wrong. Try improving your logic with a "AND" type conjunction.
One test is worth a thousand opinions.
Click the * Add Reputation below to say thanks.
Marvin, how would you rewrite this with an And?
I tried both value and text and still getting a runtime error.
It highlights the Cell.value = cell.value *1 part for the error.
will always be True.Please Login or Register to view this content.
If cell = "Letter" then cell <> "Weight" and if cell = "Weight" then cell <> "Letter".
That means you will try to increment the cell value even when there is a text value present.
Change it toPlease Login or Register to view this content.
Trevor Shuttleworth - Retired Excel/VBA Consultant
I dream of a better world where chickens can cross the road without having their motives questioned
'Being unapologetic means never having to say you're sorry' John Cooper Clarke
Thank you for your help. This did work perfectly.
I am very new to using VBA, and programming it.... I am used to thinking in terms of writing formulas in excel... not in VBA.... I would have used an if/or /then there.... I understand why it would not have worked here though.
Thanks again for your help.
You're welcome. Thanks for the rep.
If you were ORing the conditions in a formula, it wouldn't work there either.
Removed post
Last edited by alkesh4u; 07-19-2016 at 09:21 AM. Reason: Not relavant, posted in wrong location
@alkesh4u: Welcome to the forum.
Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.
If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.
Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
AND, when you create your own thread, please remember to use Code Tags ...
Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.
Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.
Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks