macro if statements

D

Donna S

I'm trying to write a simple if statement that looks at an active cell and
compares is to the data in another cell. So far I have:

If Selection.Value = ??????? Then

Please help me fill in the ???????. This is probably very simple but I'm
just learning.

Thanks,
 
M

Miguel Zapico

This is one option:
If Selection.Value = ActiveSheet.Range("A1").Value Then
It compares the value on the selected cell with the range A1 of the same
worksheet.

Hope this helps,
Miguel.
 
D

Dave Peterson

If activecell.value = worksheets("sheet99999").range("a99").value then

Remember that if you're comparing text, ABC <> aBc and ABC <> abc (and so
forth).

If lcase(activecell.value) _
= lcase(worksheets("sheet99999").range("a99").value) then

is one way around it if you want to ignore case.

Selection can be multiple cells. Activecell will be one cell.
 
Top