Forum Discussion
How to add the Rows and table automatically
- Nov 21, 2022
After downloading the workbook, right-click it in Windows Explorer and select Properties from the context menu. If you see Unblock, click it, then click OK.
You may also want to make the folder containing the workbook a trusted location for Excel (File > Options > Trust Center > Trust Center Settings... > Trusted Locations)
See the attached version. You will have to allow macros.
Right-click the sheet tab and select 'View Code' to inspect the VBA code.
- HansVogelaarNov 21, 2022MVP
After downloading the workbook, right-click it in Windows Explorer and select Properties from the context menu. If you see Unblock, click it, then click OK.
You may also want to make the folder containing the workbook a trusted location for Excel (File > Options > Trust Center > Trust Center Settings... > Trusted Locations)
- ajmal_pottekattil_yoousufNov 21, 2022Iron Contributor
- HansVogelaarNov 21, 2022MVP
Right-click the sheet tab and select 'View Code' from the context menu.
Change the Worksheet_Change event procedure to
Private Sub Worksheet_Change(ByVal Target As Range) Const MaxRows = 10 Dim NumRows As Long If Not Intersect(Range("D2"), Target) Is Nothing Then Application.ScreenUpdating = False Range("C6:E" & MaxRows + 5).Clear NumRows = Val(Range("D2").Value) If NumRows < 1 Then Exit Sub If NumRows > MaxRows Then MsgBox "The maximum is " & MaxRows, vbExclamation Exit Sub End If Range("C6:E" & NumRows + 5).Borders.LineStyle = xlContinuous Range("E6:E" & NumRows + 5).Formula = "=D6-C6" Application.ScreenUpdating = True End If End Sub