Dim strStuNum As String
Dim strStuName As String
strStuNum = InputBox("Student Number:")
铅铅圆 strStuName = InputBox("Student Name:")
Debug.Print strStuNum
Debug.Print strStuName
End Sub
运激颂行上述过程后,立即窗口(Ctrl+G)中将输出程序运行时用户输入的学号和姓名。槐塌
按alt+f11进vba编辑,双击thisworkbook,贴上芹纳陪以下代码Option Explicit
Sub color()
Dim isnum As Boolean
Dim c, r, i, j As Integer
i = 1
j = 1
' 循环嫌蠢选择的每一行。
For r = 1 To Selection.Rows.Count
' 循茄含环选择的每一列。
For c = 2 To Selection.Columns.Count
If Selection.Cells(r, c).Text = Selection.Cells(r, c - 1).Text Then
i = i + 1
Else
Cells(Selection.Cells(r, c).Row, Selection.Columns.Count + j).Value = i
i = 1
j = j + 1
End If
'
Selection.Cells(r, c).Interior.ColorIndex = ci
Next c
Cells(Selection.Cells(r, c).Row, Selection.Columns.Count + j).Value = i
i = 1
j = 1
Next r
End Sub
关闭vba后,选中数值范围,按Alt+f8执行宏
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)