选择列范围内的特定单元格

时间:2015-05-22 20:04:10

标签: excel vba excel-vba

我有一个记录学生出勤率的Excel文件。我有一个宏合并ActiveCell.Range("A1:A50")并在其中写“星期日”。我想要做的事情是:

  1. 检查活动单元格是否在D列到AH列。
  2. 如果步骤1为真,则激活该列的单元格9(“如果活动单元格为F20或F100,则宏应将其更改为F9而不更改用户选择的列)
  3. 到目前为止,这是我的代码:

    Sub Sunday()
    Dim myarr(4 To 34) As Integer
    Dim col As Integer
    col = ActiveCell.Column
    If col = myarr Then
       ActiveSheet.Cells(9).Select
    
       'code to merge range and enter "Sunday"
    
    Else
       On Error Resume Next
    End if
    End Sub
    

1 个答案:

答案 0 :(得分:0)

Sub Sunday()

    Dim col As Long
    col = ActiveCell.Column

    If col >= 4 and col <=43 Then

       ActiveSheet.Cells(9, col).Select

       'code to merge range and enter "Sunday"

    Else

    End if

End Sub