Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel 如何让我的代码从现有的电子表格中输出特定的文本?_Excel_Vba_Excel Formula - Fatal编程技术网

Excel 如何让我的代码从现有的电子表格中输出特定的文本?

Excel 如何让我的代码从现有的电子表格中输出特定的文本?,excel,vba,excel-formula,Excel,Vba,Excel Formula,我目前正在对我的VBA代码进行组合限制,个人不能一起选择某些选项。目前代码正常工作,但在显示所有错误的日志页面上,我无法让代码显示受限制的两种组合(参考代码“&rs.Cells(r,4)&”)。我真的想让日志说明两个受限制的模块,我被卡住了/弄糊涂了,我需要输入什么文本来确保实现这一点 任何帮助都将不胜感激 excluded = True For r = 3 To rs.Cells(Rows.Count, 4).End(xlUp).Row If WorksheetFunc

我目前正在对我的VBA代码进行组合限制,个人不能一起选择某些选项。目前代码正常工作,但在显示所有错误的日志页面上,我无法让代码显示受限制的两种组合(参考代码“&rs.Cells(r,4)&”)。我真的想让日志说明两个受限制的模块,我被卡住了/弄糊涂了,我需要输入什么文本来确保实现这一点

任何帮助都将不胜感激

excluded = True
    For r = 3 To rs.Cells(Rows.Count, 4).End(xlUp).Row
        If WorksheetFunction.CountIf(rq.Rows(i), rs.Cells(r, 4).Text) > 0 And _
            WorksheetFunction.CountIf(rq.Rows(i), rs.Cells(r, 5).Text) > 0 Then
            excluded = False
        End If
    Next r
    
    If excluded = False Then
        logNextRow = logNextRow + 1
        lg.Cells(logNextRow, 1) = studentID
        lg.Cells(logNextRow, 2) = "Student selected restricted combination - " & rs.Cells(r, 4) & ""
        isLog = True
        'GoTo nxti
    End If

将日志记录移动到循环内部

s1尺寸为字符串,s2尺寸为字符串
对于r=3到rs.Cells(Rows.Count,4)。结束(xlUp)。行
s1=rs.Cells(r,4).Text
s2=rs.Cells(r,5)。文本
如果工作表function.CountIf(rq.Rows(i),s1)>0和_
工作表function.CountIf(rq.Rows(i),s2)>0则
logNextRow=logNextRow+1
lg.单元格(logNextRow,1)=学生ID
lg.Cells(logNextRow,2)=“学生选择的受限组合-”&s1&&s2
如果结束
下一个r

非常感谢!