Results 1 to 20 of 26

Thread: Disable Cut, Copy, Paste Macro for One Column

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #18
    VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,709
    Location
    My first read shows to change these subs
    Private Sub Workbook_Activate() 
        ActiveSheet.Range("A1").Select
        Application.CellDragAndDrop = False 
    End Sub 
    
    Private Sub Workbook_Open()
        ActiveSheet.Range("A1").Select
        Application.CellDragAndDrop = False
    End Sub
    It is Very, Very dangerous to use Sheet.Index. It is equally dangerous to use Sheets(OneIndexNumber). Only if you are looping thru all sheets in a workbook should you use Sheets(i).

    Here is how I would do this sub.

    Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    Dim ShtName As String
      ShtName = Sh.Name
    Dim Col As Long
      Col = Target.Column
    'For certain columns on certain sheets, change Macro name
        If ShtName = "Sheet2" And Col = 15 Then Application.Run ("fecha_hoy")
       If ShtName = "Sheet3" And (Col = 3 Or Col = 13) Then Application.Run ("fecha_hoy")
    Last edited by Aussiebear; 04-08-2023 at 04:17 AM. Reason: Adjusted the code tags
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •