On Error Resume Next For j1 = 0 To 4 ' 执行5次循环 j2 = InputBox("数值=", "请输入数值") ' 输入对话框 j3 = j3 & " " & j2 ' 数据拼接 If j2 Mod 2 = 0 Then ' 如果余数是0,则为偶数 str1 = str1 & " " & "偶数"Else str1 = str1 & " " & "奇数"...
可以用函数:=IF(MOD(Y,2)=1,"奇数","偶数")在VBA中是这样的:ActiveCell.FormulaR1C1 = "=IF(MOD(Y,2)=1,""奇数"",""偶数"")" 可用RC的值更改对哪个单元格进行判断,如RC[-1]所以表示前一单元格
Sub xx() For i = 11 To 26 n = Cells(4 ^ 8, i).End(3).Row ji = 0 ou = 0 Do While Cells(n, i) <> "" And IsNumeric(Cells(n, i)) If Cells(n, i) Mod 2 = 0 Then If ji >= 3 Then Cells(n + 1, i).Resize(ji).Interior.ColorInde...
(一)VBA程序代码:Sub input_n()Dim j1, j2, j3, str1On Error Resume NextFor j1 = 0 To 4 '执行5次循环 j2 = InputBox("数值=", "请输入数值") '输入对话框 j3 = j3 & " " & j2 '数据拼接 If j2 Mod 2 = 0 Then '如果余数是0,则为偶数 str1 = str1 & "...
EXCEL VBA 如何判断奇数和偶数列并分别求值 (求助高手) VBA 如何判断奇数和偶数列并分别求值判断列最后相连的4个单元是否出现全奇数或者全偶数同时4个不同的奇数或者偶数将结果输入到下面一个单元(如上图所示)
If y = 1 Then GoTo 10 For j = y To y - 3 Step -1 If Cells(j, i) Mod 2 = 0 Then k1 = 1 Else k2 = 1 End If Next j If k1 = 1 And k2 = 1 Then Cells(y + 2, i) = "NG"ElseIf k1 = 1 And k2 = 0 Then Cells(y + 2, i) = "0"Else Cells(y +...
语句:d = Day(Range("a11")) Mod 2 下面的代码测试通过:Sub x()d = Day(Range("a11")) Mod 2 Debug.Print d End Sub
=1,格式填充红色)如果你非要用VBA,代码如下:Sub test()Dim cell As Range For Each cell In Range("A1:B4")If cell <> "" Then If cell Mod 2 = 1 Then cell.Interior.Color = vbRed Else cell.Interior.Color = vbGreen End If End If Next cell End Sub 请自己修改粗体部分 ...
,你自己参考使用吧 Sub test()For i = 1 To 20 a = i Mod 2 '求2的余数,余数是0的是偶数.If a = 0 Then Range("A" & i).Interior.ColorIndex = 3 '改变背景色 Else Range("A" & i).Font.ColorIndex = 4 '改变字的颜色 End If Next End Sub 下面是excel默认颜色编号列表 ...