Deleting a VBA line is a standard and commonly used procedure by developers. However, for less experienced users, this operation may cause some difficulties.
Instructions
Step 1
Make sure you understand the syntax for the delete line command using the Delete command. So for a row containing an active cell, the command will look like ActiveCell. EntireRow. Delete, and the need to delete a certain number of rows will change it to Rows ("number_first_line: number_of_last_line"). Delete (for Excel).
Step 2
Use a similar syntax for the delete selected row command in VBA, but with advanced options. To do this, first of all define the required action: Private Sub Delete line_Click (). Specify the required application Dim ea As Excel. Application and select the required workbook Dim ewb As Excel. Workbook. Then point to the Dim ews As Excel. Worksheet document page to be edited.
Step 3
Skip one line and enter Set XLAp = CreateObject (Class: = "Excel. Application"). Set the exact placement on the following line: Set XLWb = XLAp. Workbooks. Open ("drive_name: 1.xls") Use the following value: Set XLWs = XLWb. ActiveSheet.
Step 4
Skip another line and enter the value of the selected job: XLWs. Rows (1). Delete. Save the edited document: XLWb. Save. Quit the open source application: XLAp. Quit.
Step 5
Skip the next line and replace the variables with memory objects: Set XLWs = Nothing. Repeat the same command for each open variable: Set XLWb = Nothing and finally the last one: Set XLAp = Nothing. Finish the command with the standard End Sub.
Step 6
Use macros to perform more complex operations to delete unnecessary lines in a document. To do this, create a new Excel workbook and enter the required values. Open the "Service" menu of the upper toolbar of the program window and select the "Macro" item. Select the "Visual Basic Editor" sub-item and expand the "Insert" menu. Select the "Module" item and insert the created document. Return to the "Tools" menu and again go to the "Macro" item. Use the "Macros" sub-item and specify the newly created one. Run the macro by clicking the Run button.