ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   macro if statements (https://www.excelbanter.com/excel-discussion-misc-queries/90559-macro-if-statements.html)

Donna S

macro if statements
 
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,

Don Guillett

macro if statements
 
in the simplest form
if selection.value=range("a1") then msgbox "Hi"

--
Don Guillett
SalesAid Software

"Donna S" <Donna
wrote in message
...
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,




Miguel Zapico

macro if statements
 
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.

"Donna S" wrote:

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,


Dave Peterson

macro if statements
 
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.


Donna S wrote:

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,


--

Dave Peterson

Donna S

macro if statements
 
How do I ask: if selection.value = the value in the cell offset (0,-4)??????

"Miguel Zapico" wrote:

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.

"Donna S" wrote:

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,



All times are GMT +1. The time now is 06:50 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com