Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.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
Vba Msgbox新行后的循环结果_Vba_Loops_Msgbox - Fatal编程技术网

Vba Msgbox新行后的循环结果

Vba Msgbox新行后的循环结果,vba,loops,msgbox,Vba,Loops,Msgbox,我有一个循环在一列中查找文本(正在工作),我想将结果发布到MsgBox中,但是当我在循环内外使用MsgBox时,我将为找到的每个结果获取一个MsgBox,或者仅为一个MsgBox和一个结果获取一个MsgBox。我想做的是让它在1 msgbox中发布每个结果,并在每个结果之后换行 我知道第一个代码不是寻找重复代码的最漂亮或最好的方法,我应该使用数组,但这是我让它工作的唯一方法 第一个代码查找重复项(与问题无关): 您需要保留旧值txt txt = txt & "Duplicates fou

我有一个循环在一列中查找文本(正在工作),我想将结果发布到MsgBox中,但是当我在循环内外使用MsgBox时,我将为找到的每个结果获取一个MsgBox,或者仅为一个MsgBox和一个结果获取一个MsgBox。我想做的是让它在1 msgbox中发布每个结果,并在每个结果之后换行

我知道第一个代码不是寻找重复代码的最漂亮或最好的方法,我应该使用数组,但这是我让它工作的唯一方法

第一个代码查找重复项(与问题无关):


您需要保留旧值
txt

txt = txt & "Duplicates found for" & " " & ws.Range("A" & i).Value & " " & "in" & ws.Range("L" & i).Value & vbNewLine

您需要保留旧值
txt

txt = txt & "Duplicates found for" & " " & ws.Range("A" & i).Value & " " & "in" & ws.Range("L" & i).Value & vbNewLine
txt = txt & "Duplicates found for" & " " & ws.Range("A" & i).Value & " " & "in" & ws.Range("L" & i).Value & vbNewLine