大家好,这是我的代码
但是当我运行时没有任何事情发生,显然它在中断模式(调试)中运行良好。 我能做什么 ?欢呼声
public function destroy($id)
{
$input = Request::all();
Like::whereProjectId($id)->whereUserId(Auth::user()->id)->delete();
return redirect('projects/'.$input['project_id']);
}
应该按照A列中找到的年份的colours'name填充B列
答案 0 :(得分:0)
我不确定 j var在哪里发挥作用;我想,它涉及一些被认为不重要的代码被删除了。
Sub Button2_Click()
Dim i As Long, j As Long, n As Long
Dim Ws As Worksheet
Set Ws = ActiveSheet
With Ws
n = Ws.Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To n
Select Case .Cells(i, "A").Value2
Case 2015, 2011
.Cells(i, 2).Value2 = "blue"
Case 2001, 2003
.Cells(i, 2).Value2 = "green"
Case 2014, 2006
.Cells(i, 2).Value2 = "red"
End Select
j = j + 1
Next i
End With
End Sub
Select Case statement可以使用以逗号分隔的列表进行Xor比较。
答案 1 :(得分:0)
尝试以下代码。你说有大约20K行,所以所有的计算都在数组上进行,以获得更好的性能。
Sub Button2_Click()
Dim years As Variant
Dim colors() As Variant
Dim i As Long
Dim ws As Excel.Worksheet
Dim lastRow As Long
'------------------------------------------------------
Set ws = Excel.ActiveSheet
'Read the values from column A to array - it will make the calculations faster.
With ws
lastRow = .Cells(.Rows.Count, 1).End(xlUp).Row
years = .Range(.Cells(1, 1), .Cells(lastRow, 1))
End With
'Resize [colors] array to adjust its size to the size of [years] array.
ReDim colors(LBound(years, 1) To UBound(years, 1), 1 To 1)
For i = LBound(years, 1) To UBound(years, 1)
Select Case years(i, 1)
Case 2015, 2011: colors(i, 1) = "blue"
Case 2001, 2003: colors(i, 1) = "green"
Case 2014, 2006: colors(i, 1) = "red"
End Select
Next i
'Paste the result array back into the worksheet
ws.Cells(1, 2).Resize(UBound(years) - LBound(years) + 1, 1) = colors
End Sub