+ Reply to Thread
Results 1 to 6 of 6

Lock Cell After Data Import from an External Program

  1. #1
    Registered User
    Join Date
    08-16-2017
    Location
    USA
    MS-Off Ver
    2013
    Posts
    3

    Lock Cell After Data Import from an External Program

    So i am having major grief trying to figure this out. I have data acquisition software (DASYLab) that is gathering certain data for me. I have the data programmed to dump in to an excel file from the acquisition software. Once in the excel file, it is not allowed to be edited in any way. The problem I am running across is that when running my VBA that locks the selected group of cells where the data dumps, it isnt triggered. It only triggers once the actual cell is physically selected and any info is put in the cell. Once clicked out of, the cell that was just edited is locked. I cannot figure out how to trigger the cells to lock upon data dump. Please help!
    Here is my code:

    1 Private Sub Worksheet_Change(ByVal Target As Range)
    2 Dim xRg As Range
    3 On Error Resume Next
    4 Set xRg = Intersect(Range("A1:E300"), Target)
    5 If xRg Is Nothing Then Exit Sub
    6 Target.Worksheet.Unprotect Password:="123"
    7 xRg.Locked = True
    8 Target.Worksheet.Protect Password:="123"
    9 End Sub

  2. #2
    Valued Forum Contributor
    Join Date
    04-24-2014
    Location
    United States
    MS-Off Ver
    Office 365 ProPlus
    Posts
    853

    Re: Lock Cell After Data Import from an External Program

    Please place your code in [ code ] tags.

    It may be easier to simply lock and password protect the workbook or worksheet when you first open the file. But of course you don't want to have add the code to each file you export from your data acquisition software. So does the file export with the same name each time? And stored in the same location? Perhaps you lock and password protect all of the file exports in a particular folder each time you open excel.

  3. #3
    Valued Forum Contributor
    Join Date
    09-01-2013
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2010
    Posts
    324

    Re: Lock Cell After Data Import from an External Program

    I believe your code won't work if your software is just pasting the data in. That won't trigger a change in a cell.

    Is the workbook opened and closed by the software? If so then this can be executed before the workbook is closed.

    Please Login or Register  to view this content.
    Last edited by playaller; 08-16-2017 at 12:10 PM.


    Shelton A.
    If Helpful, Add Reputaion!

  4. #4
    Registered User
    Join Date
    08-16-2017
    Location
    USA
    MS-Off Ver
    2013
    Posts
    3

    Re: Lock Cell After Data Import from an External Program

    Pardon my lack of knowledge and code paste. I am in no way remotely familiar with any of this and am learning from the school of google so please bear with me and i appreciate any and all help.

    The data is automatically imported via DDE from the data acquisition software to a saved workbook template. After batch production is complete and it is the end of the day, and the technician selects "stop recording" in the software, it is programmed to automatically "save as" the template with the date/time. After the "save as" copy is stored, the template is closed without saving changes to the template, thus returning it back to a blank template.

    pt - i have tried to lock and password protect the cells, but if i remember correctly, the data was not able to be imported

    Thanks

  5. #5
    Valued Forum Contributor
    Join Date
    04-24-2014
    Location
    United States
    MS-Off Ver
    Office 365 ProPlus
    Posts
    853

    Re: Lock Cell After Data Import from an External Program

    Quote Originally Posted by CRLCHS View Post
    Pardon my lack of knowledge and code paste. I am in no way remotely familiar with any of this and am learning from the school of google so please bear with me and i appreciate any and all help.

    The data is automatically imported via DDE from the data acquisition software to a saved workbook template. After batch production is complete and it is the end of the day, and the technician selects "stop recording" in the software, it is programmed to automatically "save as" the template with the date/time. After the "save as" copy is stored, the template is closed without saving changes to the template, thus returning it back to a blank template.

    pt - i have tried to lock and password protect the cells, but if i remember correctly, the data was not able to be imported
    Where is the Save As copied stored/saved to by the software? You could have macro or Excel addin that password protects all the files/workbooks within that folder.

    You could possibly run something like this password protect all the files in a particular location.

    Please Login or Register  to view this content.
    Last edited by ptmuldoon; 08-16-2017 at 01:00 PM.

  6. #6
    Registered User
    Join Date
    08-16-2017
    Location
    USA
    MS-Off Ver
    2013
    Posts
    3

    Re: Lock Cell After Data Import from an External Program

    The copies are "saved as" in the same folder as the template and then renamed under a batch # at the end of the day and moved to another location. If i am understanding your suggestion correctly - while the template is active/live and receiving data, the cells need to immediately lock after data transmitted (hence the need for the code within the template). Upon completion and in the "saved as" copy, the data also needs to remain locked

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. VBA program for cell increment from external file
    By dineshkdk in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-17-2016, 04:19 AM
  2. Cell lock program
    By heyaop in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-21-2014, 11:53 PM
  3. [SOLVED] execute external program when cell reaches certain value
    By Brendan DJ Murphy in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-08-2011, 10:27 AM
  4. Import External Data doesn't import
    By JakeAy in forum Excel General
    Replies: 7
    Last Post: 01-26-2010, 03:58 AM
  5. [SOLVED] PLEASE!! How can I un-grey the 'Data-Import External Data-Import Data' option ???
    By kirkm in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 08-08-2006, 05:05 AM
  6. Copying data to an external Program
    By Debby Bunce in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 06-08-2005, 08:05 PM
  7. “Import External Data:Import External Data
    By Jeff in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 05-03-2005, 06:06 PM

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