我要在活动工作表而不是工作表1上使用此代码?
Sub Concatenate()
' Concatenate two columns
Dim l As Long, lRow As Long
With Sheets("Sheet1")
lRow = .Range("A" & Rows.Count).End(xlUp).Row
For l = 2 To lRow
Sheets("Sheet1").Cells(l, 3) = .Cells(l, 1) & " " & .Cells(l, 2)
Next l
End With
End Sub
答案 0 :(得分:1)
编辑:我误会了。这将适用于所有工作表。
$stmt = $pdo->prepare('SELECT DISTINCT name,location
FROM answers
WHERE name LIKE concat("%", :variable1, "%") OR
location LIKE concat("%", :variable2, "%")');
$stmt->execute([':variable1' => $search_for, ':variable2' => $search_for]);
使用此代码仅适用于活动工作表
Dim l as Long, lRow as Long
For Each ws in Activeworkbook.Worksheets
With Sheets(ws)
lRow = .Range("A" & Rows.Count).End(xlUp).Row
For l = 2 To lRow
Sheets("Sheet1").Cells(l, 3) = .Cells(l, 1) & " " & .Cells(l, 2)
Next l
End With
Next ws
End Sub