davefaust78
New Member
- Joined
- Sep 11, 2017
- Messages
- 8
- Office Version
- 365
- Platform
- Windows
Hi,
I am writing a VBA code to automatically clean up some excel reports I run on a regular basis and I have a situation where I am stuck.
Column J of my data contains Country Names and column K of my data has State Names.
Here's what I need:
If the values in column J are not equal to either United States or Canada, then clear the states value name in the adjacent cell.
For example, Here's how my data currently looks:
[TABLE="class: grid, width: 200, align: left"]
<tbody>[TR]
[TD]Canada[/TD]
[TD]BC[/TD]
[/TR]
[TR]
[TD]United States[/TD]
[TD]TX[/TD]
[/TR]
[TR]
[TD]Brazil[/TD]
[TD]Rio de Janeiro[/TD]
[/TR]
[TR]
[TD]United States[/TD]
[TD]NY
[/TD]
[/TR]
[TR]
[TD]Canada[/TD]
[TD]SK[/TD]
[/TR]
[TR]
[TD]Chile[/TD]
[TD]Santiago[/TD]
[/TR]
[TR]
[TD]Brazil[/TD]
[TD]Goias[/TD]
[/TR]
[TR]
[TD]Italy[/TD]
[TD]Roma[/TD]
[/TR]
[TR]
[TD]United States[/TD]
[TD]CA[/TD]
[/TR]
[TR]
[TD]United Kingdom[/TD]
[TD]Surry[/TD]
[/TR]
</tbody>[/TABLE]
For each of the countries that are not equal to United States or Canada, I need the state values cleared.
It's driving me crazy as I'm relatively new to VBA. Any help that anyone can offer would be a huge lifesaver.
I'd like to run this as it's own sub.
Thank you.
Regards,
Dave
I am writing a VBA code to automatically clean up some excel reports I run on a regular basis and I have a situation where I am stuck.
Column J of my data contains Country Names and column K of my data has State Names.
Here's what I need:
If the values in column J are not equal to either United States or Canada, then clear the states value name in the adjacent cell.
For example, Here's how my data currently looks:
[TABLE="class: grid, width: 200, align: left"]
<tbody>[TR]
[TD]Canada[/TD]
[TD]BC[/TD]
[/TR]
[TR]
[TD]United States[/TD]
[TD]TX[/TD]
[/TR]
[TR]
[TD]Brazil[/TD]
[TD]Rio de Janeiro[/TD]
[/TR]
[TR]
[TD]United States[/TD]
[TD]NY
[/TD]
[/TR]
[TR]
[TD]Canada[/TD]
[TD]SK[/TD]
[/TR]
[TR]
[TD]Chile[/TD]
[TD]Santiago[/TD]
[/TR]
[TR]
[TD]Brazil[/TD]
[TD]Goias[/TD]
[/TR]
[TR]
[TD]Italy[/TD]
[TD]Roma[/TD]
[/TR]
[TR]
[TD]United States[/TD]
[TD]CA[/TD]
[/TR]
[TR]
[TD]United Kingdom[/TD]
[TD]Surry[/TD]
[/TR]
</tbody>[/TABLE]
For each of the countries that are not equal to United States or Canada, I need the state values cleared.
It's driving me crazy as I'm relatively new to VBA. Any help that anyone can offer would be a huge lifesaver.
I'd like to run this as it's own sub.
Thank you.
Regards,
Dave