Help to set default in a list

gio123bg
05-28-2010, 04:32 AM
Hi all,
I use this VBA code for setting a list i(approved, under review, blank) in a cell but I need to set a defaul value if this condition is respected.

Range(cellist).Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:=namerange
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With


IF cell(x,y).value is blank
set "approved" in the list
ELSE
set "under review" in the list

otherwise live the list vithout setting values.

Any suggestion will be well appreciated.

Regards,

Giovanni

zebulon72
05-28-2010, 06:14 AM
Hi all,
I use this VBA code for setting a list i(approved, under review, blank) in a cell but I need to set a defaul value if this condition is respected.

IF cell(x,y).value is blank
set "approved" in the list
ELSE
set "under review" in the list

otherwise live the list vithout setting values.



Is it the If-expression only you are thinking about? I think you are pretty much there already in that case.


IF cells(x,y) = "" then
cells(x,y) = "Approved"
ELSE
cells(x,y) = "Under review"
End if

gio123bg
05-28-2010, 06:27 AM
Hi and thanks for the quick reply.

Let's suppose to have a list in cell(2,2) with values a,b,c and blank

if I have this VBA code

cell(2,2) = "a" I see my list without setting the "a" (for me, default value).

Any idea?

Thanks.

Regards,

Giovanni

zebulon72
05-31-2010, 12:55 AM
I honestly don't know what you want to do with your code.
A guess is that you want to check column 2. If a cell in column 2 is blank you want to set it to default value "a"?
e.g. if you have data in column 1 (without blanks in this case) you could do a loop that sets all blanks to "a".



dim i as integer ' your row counter in you loop
i=1
Do until cells(i, 1) = ""
IF cells(i,2) = "" then
cells(i,2) = "a" 'or "Approved"?
End if
Loop

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum