VBA Evaluate / Excel If: Can I return anempty string?

DavidExcel

New Member
Joined
Feb 12, 2019
Messages
10
In my code, I use Evaluate to create an If statement as I would in Excel.
It seems to behave as it should except I can't seem to return an empty string (""). I have to say that this range 'NewDiscountPLColumn' where results go is formatted as %.

I have tried to put a random value, and it does return it when the first column is empty, so I would think it is working.
Now, if I put 'Blank', 'vbNullString', or even a reference to an empty cell in Excel, it always seem to return 0%.

I have even tried to replace the value after the evaluate calculation, and no luck.

Below is my code:

Code:
    Dim NewDiscountPL As Variant
    NewDiscountPL = InputBox("Enter the new discount to apply (without % sign) to all Product Lines")


    Dim ProductLinesColumn As Range
    Set ProductLinesColumn = Range("F42:F91")
    Dim NewDiscountPLColumn As Range
    Set NewDiscountPLColumn = Range("H42:H91")
    NewDiscountPLColumn = Evaluate("If(IsBlank(" & ProductLinesColumn.Address & ")," & [I][B]Blank[/B][/I] & "," & NewDiscountPL & "/ 100)")

ANy ideas?
Thanks in advance.
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Code:
NewDiscountPLColumn = Evaluate("If(IsBlank(" & ProductLinesColumn.Address & "),""""," & NewDiscountPL & "/ 100)")
 
Upvote 0

Forum statistics

Threads
1,203,524
Messages
6,055,906
Members
444,832
Latest member
bgunnett8

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