LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Deletion Code - Fix please

Hi, could someone please help me modify my deletion code as follows:

I need the following code to be slightly modified so that when a user
selects a cell in column Y, then the contents in cells Y:AQ and AY:AZ
are deleted.

For example: if a user selects cell: Y14, then I need the cell contents
Y14:AQ14 and AY14:AZ14 to be deleted.

Sub Deleted_Part_1()


Dim Y_Column As Range

On Error Resume Next

ActiveSheet.Unprotect

Do

Set Y_Column = Application.InputBox("Click in the cell in the
Incumbent's Service column that corresponds with the record you wish to
delete: ", "Please Choose Correct Cell in the Incumbent's Service
column", Cells(ActiveCell.Row, 1).Address, , , , , 8)
If Err.Number < 0 Then
Call OperationCancelled(True)
Exit Sub
End If
Loop Until Y_Column.Column = 1
Call Deleted_Part_2(Y_Column(1))
ActiveWindow.SmallScroll Down:=-65000
Range("A2").Select

End Sub

Sub Deleted_Part_2(Where As Range)

Dim Msg As String
Dim Ans As Long

Where.Select

Msg = "Click on the <OK Button If You Wish To Continue In Deleting
The Current Selected Record, Or Click On the <Cancel Button To Cancel
This Operation"
Ans = MsgBox(Msg, vbOKCancel)

Application.ScreenUpdating = False

If Ans = vbOK Then

ActiveCell.Rows("1:1").EntireRow.Select

Selection.Delete Shift:=xlUp

Range("A2").Select

With Sheets("Data")
'Following line of code is like selecting the last cell
'in the column and holding the Ctrl key and press Up arrow
'It then names the cell.
.Cells(.Rows.Count, "A").End(xlUp).Name = "LastCell"

End With

Range("A2").Select

ActiveWindow.SmallScroll ToRight:=-9

Application.ScreenUpdating = True

Msg = "The Selected Record Is Now Deleted"
Ans = MsgBox(Msg, vbOKOnly)

Range("A2").Select

End If

If Ans = vbCancel Then

Msg = "The Deletion Procedure Has Now Been Cancelled"
Ans = MsgBox(Msg, vbOKOnly)
Exit Sub

End If

ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True _
, AllowSorting:=True, AllowFiltering:=True,
AllowUsingPivotTables:=True
ActiveSheet.EnableSelection = xlNoRestrictions


End Sub

Sub OperationCancelled(Optional Cancelled As Boolean)

MsgBox "You cancelled this operation."

ActiveWindow.SmallScroll ToRight:=-27

End Sub



*** Sent via Developersdex http://www.developersdex.com ***
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA code needed for auto deletion upon opening JAbels001 Excel Discussion (Misc queries) 2 March 8th 10 04:38 PM
Row Deletion SiH23 Excel Programming 1 February 27th 09 07:04 PM
name deletion rk0909 Excel Discussion (Misc queries) 2 January 4th 08 11:03 PM
Row Deletion Dan Excel Programming 3 September 1st 04 10:40 PM


All times are GMT +1. The time now is 09:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"