Logic behind If Not Selection.Value > "" ?

Krisz06

New Member
Joined
May 25, 2017
Messages
26
Hello, it will be a stupid question most probably...

Why in VBA we are using the following:
"If Not Selection.Value > ""

If I'm correct that this basically means "if selection value is not bigger than nothing", which mean if value is 0..
There is no "If Selection.Value = "" for this or why the more complicated one is the used?



I'm a beginner and has no programming background, so this may be some obvious thing, but I'm just confused about it.
But how I see this code in a lot of places I assume that this it the VBA logic and I just need to get used to it :biggrin:
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
I have never see the first criteria in my life ...

Normally we use "If Selection.Value <> "" Then" or "If Selection.Value = "" Then"

The not argument is more used in situation with True or False formula like IsNumeric or IsEmpty.

I had like to know where you often see this. In fact, it's not testing for "bigger than 0" but "bigger than nothing". What can be bigger than nothing?
 
Last edited:
Upvote 0
Thank you for your reply Roxxien,

Sorry, I haven't put the whole sentence in the original post. The full looks like this:
If Not Selection.Value > "" Then Exit Do


So, thanks for the clarification that "If Selection.Value = "" Then" is also used in vba..
I was checking it from the Mr Excel book and also from various google searches and I saw always this logical twist with the "Not"... so now I understand


And just checked the following 3:
If Not Selection.Value > "" Then Exit Do
If Selection.Value = 0 Then Exit Do
If Selection.Value = "" Then Exit Do
give the same result. I will use the middle one in the future
 
Upvote 0

Forum statistics

Threads
1,214,897
Messages
6,122,141
Members
449,066
Latest member
Andyg666

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top