I have some problems with vba. I have a button in excell, and if i run makro from excell it takes twice much time than if I run from VBA developer. If I run from VBA developer it sets my border and background color corectlly (I tried runing makro from button several times). if i ran the code from button excel it just formats(bg color, border) first 20 rows, but vba developer formats all of rows. Below is my code. Regards
Sheets("Master plan").Cells.Clear
lrm = 1
With Worksheets("Mater plan")
For Each ws In Sheets(Array("1L", "5L", "20L"))
LR = ws.Range("A" & Rows.Count).End(xlUp).Row
.Range("D" & lrm).Resize(LR, 1) = ws.Range("C12:C" & LR).Value2
.Range("A" & lrm).Resize(LR, 1) = ws.Range("A12:A" & LR).Value2
.Range("B" & lrm).Resize(LR, 1) = ws.Range("L12:L" & LR).Value2
.Range("C" & lrm).Resize(LR, 1) = ws.Range("L12:L" & LR).Value2
lrm = lrm + Range("A1:A" & LR).Rows.Count
Next
End With
I think problem starts from here...
Dim c As Range
Dim SrchRng
For Each ws In Sheets(Array("Master plan"))
lastRow = ws.Range("A" & Rows.Count).End(xlUp).Row
For i = lastRow To 1 Step -1
If ws.Cells(i, 1).Text = "#N/V" Or ws.Cells(i, 1).Text = "stop" Then
ws.Cells(i, 1).EntireRow.Delete
End If
Next i
Next
Dim LR3 As Long
LR3 = Range("B" & Rows.Count).End(xlUp).Row
Sheets("master plan").Range("A1:A" & LR3).Borders(xlEdgeRight).LineStyle = xlContinuous
Sheets("master plan").Range("B1:B" & LR3).Borders(xlEdgeRight).LineStyle = xlContinuous
Sheets("master plan").Range("C1:C" & LR3).Borders(xlEdgeRight).LineStyle = xlContinuous
Sheets("master plan").Range("D1:D" & LR3).Borders(xlEdgeRight).LineStyle = xlContinuous
Sheets("master plan").Range("B1:B" & LR3).NumberFormat = "ddd dd.mm"
Sheets("master plan").Range("C1:C" & LR3).NumberFormat = "ddd dd.mm"
Sheets("master plan").Range("A1:A" & LR3).Interior.Color = RGB(253, 233, 217)
Sheets("master plan").Range("B1:B" & LR3).Interior.Color = RGB(218, 238, 243)
Sheets("master plan").Range("C1:C" & LR3).Interior.Color = RGB(218, 238, 243)
Sheets("master plan").Range("D1:D" & LR3).Interior.Color = RGB(235, 241, 222)
Sheets("master plan").Columns("A:E").ColumnWidth = 15