Even ODD Row Number Query

gsaini

New Member
Joined
Apr 8, 2011
Messages
15
Hi All, I am able to find out the correct function to work with Even and Odd rows.My small requirement is as below.

z = ActiveCell.row
If z = evern number then
MsgBox("Even row selected")
else
MsgBox("Odd row Selected")

I tried using MOD but Excel doen't like it.

Any Advice? Please
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
The syntax for MOD is slightly different in VBA then it is in a cell formula..

In a formula it would be

=IF(MOD(z,2)=0,"It's Even",It's Odd")


In VBA it's written like

Code:
If z Mod 2 = 0 Then
    Msgbox "It's Even"
Else
    Msgbox "It's Odd"
End If
 
Upvote 0

Forum statistics

Threads
1,224,597
Messages
6,179,813
Members
452,945
Latest member
Bib195

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