New rows

Hatye

Board Regular
Joined
Jan 11, 2010
Messages
143
Hi,

I have a macro to insert numerous rows, depending on content in other sheets and the macro does work. However, it is extremely slow. Therefor I wonder if anyone knows how to speed it up?

Just let me know if you need any more information!

Thank you in advance
smile.gif


Code:
Private Sub NyRad_Alle()


If Rapport_NyRadPunkt.TextBox1.Value = "" Then Rapport_NyRadPunkt.Hide
If Rapport_NyRadPunkt.TextBox1.Value = "" Then Exit Sub


Application.ScreenUpdating = False


AntallRaderimport = Sheets("Rapport_Import").Range("A" & Rows.Count).End(xlUp).Row
SisteRadPunktliste = Sheets("Rapport").Range("B62:B" & Rows.Count).End(xlDown).Row


AntallNyeRader = AntallRaderimport - SisteRadPunktliste + 61


    intLastFilledCellRow = Sheets("Rapport").Range("B61").End(xlDown).Row


For X = 1 To AntallNyeRader


    Sheets("Rapport").Range(intLastFilledCellRow + 1 & ":" & intLastFilledCellRow + 1).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    
    Sheets("Rapport").Range(intLastFilledCellRow & ":" & intLastFilledCellRow).AutoFill _
        Destination:=Sheets("Rapport").Range(intLastFilledCellRow & ":" & intLastFilledCellRow + 1), Type:=xlFillDefault
    
    With Sheets("Rapport").Range("B" & intLastFilledCellRow & ":AG" & intLastFilledCellRow).Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlHairline
    End With


Next X


Rapport_NyRadPunkt.Hide


Application.ScreenUpdating = True


End Sub
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
You seem to be copying evrything at once but then looping and doing it again try commenting out the for x = 1 to...... and the next x column.
 
Upvote 0

Forum statistics

Threads
1,203,094
Messages
6,053,507
Members
444,667
Latest member
KWR21

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top