Consulting

Results 1 to 2 of 2

Thread: Solved: VBA Print Code and Protected Sheet Problem

  1. #1

    Solved: VBA Print Code and Protected Sheet Problem

    I have a form which I have created in excel for many people on different computers to fill out. I wrote a VBA code so that columns with costs are automatically blanked out when anyone wants to print out the form. I also have protected the document so that only the cells that need to be filled in can be edited. When the sheet is unprotected, the VBA printing code works fine, but when the sheet is protected, an error with the code pops up. Some of the cost columns are locked, and others are not. I will attach the entire document for viewing. When I tried to debug the code, the line: Sheet2.Range("O34:O50").Font.ColorIndex = 2 seemed to have an issue and I'm not sure why. Any suggestions?
    Attached Files Attached Files

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Was it error 1004? If so, you need to unprotect the sheet or use the UserInterfaceOnly=True option in the sheet's Protect method. I usually set that in the workbook's Open event so that code can modify cells.

    [vba] Sheet2.Protect "ken", UserInterfaceOnly:=True
    Sheet2.Range("O34:O50").Font.ColorIndex = 2[/vba]

Posting Permissions

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