Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 262
Default Forcing a selection

I have a named range that covers data in columns A and B. (A) contains
acompany names and (B) contains the Town the company is in.

Users have the ability to delete entries that aren't theirs by selecting
both (A) and (B) across the row, right clicking and selecting delete. Finally
when asked select to shift the cells us. To add a new entry they add it to
the very bottom of the list then click on a button that runs a macro to
re-sort the list.

This works fine in practice but some users are deleting the company only and
not the town, causing things to go wrong.

How can I force the user to select both columns when deleting. It might not
always be a single line they want to delete. It might be a whole block of
entries.

Anybody got any ideas?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Forcing a selection

maybe just make a form with 1 textbox and 1 command button asking for the row
number. assign a shortcut to it, control m or something,

use this code for the command button

Private Sub CommandButton1_Click()
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
With ws.Range("A" & TextBox1.Value & ":B" & TextBox1.Value)
.Delete Shift:=xlUp
End With


End Sub

--


Gary


"Keith" wrote in message
...
I have a named range that covers data in columns A and B. (A) contains
acompany names and (B) contains the Town the company is in.

Users have the ability to delete entries that aren't theirs by selecting
both (A) and (B) across the row, right clicking and selecting delete. Finally
when asked select to shift the cells us. To add a new entry they add it to
the very bottom of the list then click on a button that runs a macro to
re-sort the list.

This works fine in practice but some users are deleting the company only and
not the town, causing things to go wrong.

How can I force the user to select both columns when deleting. It might not
always be a single line they want to delete. It might be a whole block of
entries.

Anybody got any ideas?



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Forcing a selection

Trying to detect the delete would be difficult.

What about using the Worksheet_change event to do

if Target.column < 3 then
on Error Resume Next
set rng = Range("A:B").specialCells(xlBlanks)
On Error goto 0
if not rng is nothing then
on Error go to ErrHandler
Application.EnableEvents = False

set rng1 = Intersect(rng.entireRow,Range("A:B"))
rng1.Delete Shift:xlShiftUp
end if
End if

ErrHandler:
Application.EnableEvents = True

This is an untested idea since I have minimal information on your situation.

--
Regards,
Tom Ogilvy



"Keith" wrote:

I have a named range that covers data in columns A and B. (A) contains
acompany names and (B) contains the Town the company is in.

Users have the ability to delete entries that aren't theirs by selecting
both (A) and (B) across the row, right clicking and selecting delete. Finally
when asked select to shift the cells us. To add a new entry they add it to
the very bottom of the list then click on a button that runs a macro to
re-sort the list.

This works fine in practice but some users are deleting the company only and
not the town, causing things to go wrong.

How can I force the user to select both columns when deleting. It might not
always be a single line they want to delete. It might be a whole block of
entries.

Anybody got any ideas?

Reply
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
Copy Selection - Transpose Selection - Delete Selection Uninvisible Excel Discussion (Misc queries) 2 October 23rd 07 04:18 PM
Forcing Text Kirk P. Excel Discussion (Misc queries) 2 September 26th 06 07:57 PM
forcing UDF to run Stefi Excel Worksheet Functions 4 December 29th 05 03:46 PM
Forcing a font throughout mattslav Excel Discussion (Misc queries) 3 June 8th 05 06:50 PM
Forcing a FileSaveAs John Petty Excel Programming 6 September 14th 03 01:44 AM


All times are GMT +1. The time now is 03:01 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"