View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.programming
Rowan Drummond[_3_] Rowan Drummond[_3_] is offline
external usenet poster
 
Posts: 414
Default exporting to excel

Try

Dim rngToLock As Range
Set rngToLock = Range("M2:M100") '<<adjust as required

Cells.Locked = False
rngToLock.Locked = True
On Error Resume Next
rngToLock.SpecialCells(xlCellTypeBlanks).Locked = False
On Error GoTo 0
ActiveSheet.Protect Password:="thepassword"

Regards
Rowan

Justin wrote:
im looking for the data it self to get locked. that column is always M
but it hsa to lock once te upload button was pressed
but whatever is still blank, user should be able to use the drop down

"Rowan Drummond" wrote:


The easiest way to lock these cells would be to use sheet protection. At
the end of your load macro add the code:

Cells.Locked = False
Range("A5:A9").Locked = True
ActiveSheet.Protect Password:="thepassword"

This will stop cells in the range A5:A9 being changed but still allow
changes to other cells in the sheet.

Hope this helps
Rowan

Justin wrote:

ok, the comment field is an excel cell, 5 cells to be exact(a5:a9)
the sheet has 3 extra cells after teh data is loaded to the sheet

operator ID- writing cell
comment field-drop down cell
operator comment-writing cell

as for the sheet, it isn't protected




"Rowan Drummond" wrote:



Hi Justin

I would need to know more about the comment field in order to help you.
It is not clear if this is a cell on the template sheet (perhaps linked
to the dropdown) or maybe the dropdown itself or maybe something
completely different. So:
1) Is the commment field an excel cell and if so what is it's address or
is it more than one cell we are talking about.
2) If it is not a field what is it eg Forms ComboBox, Controls Toolbox
listbox, cell comment etc
3) How is the field updated by the user before the load to access occurs.
4) Is the template sheet protected at all.

Regards
Rowan

Justin wrote:


I have another question, it has to do with the exporting to excel. Now the
code that you modify actually acts like a module for another excel sheet
(template sheet) where I import data from access. Now on this template sheet,
there is an upload button, which will call for the code (the one you helped
out with) and export all teh data and soo on

Now on this template sheet, there is a drop down where the user will pick 5
things
I need to have it that once the user press upload, that comment field will
lock so that they can not change it. Reason is that this 1 sheet is on a
share drive and 3 other people will work it. Now i wish that they can work it
in a day but sometimes 1 person will work 1 day and anotehr another and the
last a week later. The director wants to upload it even if all the work isn't
complete, upload whatever is done, and when the others are completed, upload
that data. I already know that it will upload 2wice, that is where the access
database will determine if this is a duplicate or not, if it is, then delete,
if not, save.
I don't want to 1 user to change that comment field a day later when i
upload it again. That is why i need to know a way to look a field where it
has a comment(there is 5 comments) and lock it once the user press upload.
thanks