Pass on any text value to variable

vineet78

Board Regular
Joined
Oct 22, 2017
Messages
73
Hi there

I have a drop down in cell which can be a blank or text.
Now i want to declare a variable in macro that should be equal to this cell text (if this drop down cell has text) or variable can be any text value.

As long as this cell has value , macro runs fine but when this cell is blank, then how do i tell macro that when it is blank, this variable can be any other text value.

I have tried like below
Dim zz as string

if Range("b2")<>"" then
zz=range("b2").value
else
zz="*"
end if

But above does not help as then it takes zz value as * but i want to it be any text string.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
But above does not help as then it takes zz value as * but i want to it be any text string.
Programming is very literal. It can only do what you tell it to. You cannot tell it to "do whatever it wants".
You need to be literal and tell it what value to use or give it some direction on how to locate a value to use (you cannot tell it "just use anything").
You could use a random number generator if you want it to be something random.
 
Upvote 0

Forum statistics

Threads
1,213,564
Messages
6,114,334
Members
448,567
Latest member
Kuldeep90

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