Results 1 to 5 of 5

can i used CNTRL D in PROTECTED SHEET

Threaded View

baig123 can i used CNTRL D in... 12-18-2014, 12:39 AM
6StringJazzer Re: can i used CNTRL D in... 12-18-2014, 04:48 PM
baig123 Re: can i used CNTRL D in... 12-19-2014, 12:33 AM
6StringJazzer Re: can i used CNTRL D in... 12-19-2014, 07:59 PM
Greg M Re: can i used CNTRL D in... 12-19-2014, 08:09 AM
  1. #1
    Forum Contributor
    Join Date
    03-01-2014
    Location
    Mysore
    MS-Off Ver
    Excel 2007
    Posts
    379

    can i used CNTRL D in PROTECTED SHEET

    please let ME KNOW can i used CNTRL D in PROTECTED SHEET

    Private Sub CommandButton1_Click()
      Dim cnt As ADODB.Connection
        Dim rst1 As ADODB.Recordset, rst2 As ADODB.Recordset
        Dim stDB As String, stSQL1 As 
    String, stSQL2 As String
        Dim strConn As String
        Dim wbBook As Workbook
        Dim Sheet1 As Worksheet
        Dim i
        Dim Target As Range
        
        Dim column As Integer
        Dim lnField As Long, lnCount As Long
        Dim dataStr As String
         'Instantiate the ADO-objects.
        Set cnt = New ADODB.Connection
        Set rst1 = New ADODB.Recordset
        Set rst2 = New ADODB.Recordset
    
        Set wbBook = ThisWorkbook
        Set Sheet1 = wbBook.Worksheets(1)
    
         'Path to the database.
        stDB = "mysql32"
    
         'Create the connectionstring.
        strConn = "Driver=MySQL ODBC 5.2 Unicode Driver;" _
        & "Data Source=" & stDB & ";"
    
        
    
        
           'The 1st raw SQL-statement to be executed.
          'stSQL1 = "SELECT * FROM tblbatch_headers where idBatch " & batchID & "order by col_seq asc"
    
         'The 2nd raw SQL-statement to be executed.
         stSQL2 = "SELECT * FROM  " & BMS.TextBox1 & "  where FQR_User_Code='" & Environ("username") & _
             "' and line_status in('QP')" '
         'Clear the worksheet.
          Sheet1.Range("A1:FA1").CurrentRegion.Clear
         
    
    
                With cnt
            .Open (strConn)   'Open the connection.
            .CursorLocation = adUseClient 'Necessary to disconnect the recordset.
        End With
    
         With rst1
    '       .Open stSQL1, cnt    'Create the recordset.
           Set .ActiveConnection = Nothing 'Disconnect the recordset.
         End With
    
        With rst2
            .Open stSQL2, cnt 'Create the recordset.
            Set .ActiveConnection = Nothing 'Disconnect the recordset.
        End With
        
        
    
         With Sheet1
    '        .Cells(2, 1).CopyFromRecordset rst1 'Copy the 1st recordset.
         For i = 1 To rst2.Fields.Count
                .Cells(2, i).Value = rst2.Fields(i - 1).Name
             Next i
            .Cells(3, 1).CopyFromRecordset rst2 'Copy the 2nd recordset.
       End With
    
              'If target.column < 16 Then
             'Application.EnableEvents = False
            ' Application.Undo
             'Application.EnableEvents = True
    
            ' MsgBox "You cannot do that!"
         'End If
        '  End With
          rst2.Close
            Set rst2 = Nothing
             cnt.Close
           Set cnt = Nothing
         'Release objects from the memory.
    '    rst1.Close
       '  Set rst1 = Nothing
                ActiveSheet.Unprotect Password:="password"
    
              Dim sh As Worksheet
              Dim rng As AllowEditRange
    
              Set sh = ActiveSheet
    
              For Each rng In sh.Protection.AllowEditRanges
              rng.Delete
               Next rng
    
             ActiveSheet.Protection.AllowEditRanges.Add Title:="Range1", Range:=Range("P1:BJ1000")
             ActiveSheet.protect Password:="password", DrawingObjects:=True, Contents:=True, Scenarios:=True, AllowFiltering:=True, AllowFormattingCells:=True, AllowUsingPivotTables:=True, AllowFormattingColumns:=True, userInterfaceOnly:=True, AllowFormattingRows:=True, AllowInsertingHyperlinks:=True, AllowSorting:=True
                    'ActiveCell.Select
                'Selection.Font.Bold = True
             'Colorize = myValue
    
            
    Unload Me
    End Sub
    
    
    
    Private Sub UserForm_Click()
    
    End Sub
    Last edited by baig123; 12-18-2014 at 01:07 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. allowing group/ungroup function in protected sheet
    By Elainefish in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 03-13-2023, 02:05 PM
  2. [SOLVED] outline macro not allowing filtering on a protected sheet
    By djhurayt in forum Excel General
    Replies: 1
    Last Post: 05-05-2014, 09:24 AM
  3. Replies: 1
    Last Post: 05-15-2013, 01:55 PM
  4. Allowing functions on a protected sheet
    By prince.ali in forum Excel General
    Replies: 2
    Last Post: 11-08-2007, 09:14 AM
  5. Allowing hyperlinks an a protected sheet
    By Chris Ince in forum Excel General
    Replies: 2
    Last Post: 11-07-2005, 04:30 PM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1