New Excel Forum

This forum has been moved to TeachExcel.com

Ask all future questions in the New Excel Forum.

ExcelKey

Dialog box, select rows>5, delete in multiple worksheets

Macros, VBA, Excel Automation, etc.

Dialog box, select rows>5, delete in multiple worksheets

Postby jokr1 » Thu Mar 17, 2016 8:49 pm

Code below works good for deleting rows on the active worksheet, but I would love to have a couple of changes. I am not good at VBA, this code is a sample from another place. I would like two different codes, one for the current worksheet and one for multiple worksheets.

1. I don't want to be able to delete rows 1-5 for this code. Some kind of dialog box that says: "You can only delete row "6" or below".

Code: Select all
Option Explicit

Sub DeleteMe()
    Dim Ret As Range, Cl As Range

    On Error Resume Next
    Set Ret = Application.InputBox("Mark rows to be deleted", "Delete rows", Type:=8)
    On Error GoTo 0

    ActiveSheet.Unprotect Password:="password"

    If Not Ret Is Nothing Then Ret.EntireRow.Delete

    ActiveSheet.Protect Password:="password"
End Sub



2. Another similar code as above (delete row 6 or higher) with dialog box and selection, but when I select rows in worksheet A, the same rows in worksheet B and C are also deleted.
  • 0

jokr1
Rookie
 
Posts: 1
Joined: Mar 17, 2016
Reputation: 0
Excel Version: 2013

Return to Macros and VBA Questions

Who is online

Users browsing this forum: No registered users and 39 guests