Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tim Tim is offline
external usenet poster
 
Posts: 408
Default Autofit columns, password protected

Hi there,
I have 12 sheets (Deposits) and 12 sheets (Cheques). I want the column to
autofit based on user text input. So for Deposits ( columns G and H ) ....
for Cheques ( columns I and J ). Not sure how to make them autofit and
password protect. Any ideas out there? Thanks very much.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Autofit columns, password protected

Ok, this will auto-fiit the columns A:I for you:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False

Worksheets("Sheet1").Columns("A:I").AutoFit

Application.EnableEvents = True
End Sub

You have to unprotect the sheet to enable this kind of change. If you
auto-unprotect the sheet, there is no point in protecting the sheet. You can
certainly control that with another macro though...from a post back in 2007
by 'JW'

To unprotect the sheet:
Sheets("Sheet2").Unprotect Password:="YourPassword"

To protect the sheet:
Sheets("Sheet2").Protect Password:="YourPassword"

To run a check and proceed accordingly:
Sub thiser()
Dim pw As String
pw = "YourPassword"
With Sheets("Sheet2")
If .ProtectContents = True Then
..Unprotect Password:=pw
Else
..Protect Password:=pw
End If
End With
End Sub

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Tim" wrote:

Hi there,
I have 12 sheets (Deposits) and 12 sheets (Cheques). I want the column to
autofit based on user text input. So for Deposits ( columns G and H ) ....
for Cheques ( columns I and J ). Not sure how to make them autofit and
password protect. Any ideas out there? Thanks very much.

  #3   Report Post  
Posted to microsoft.public.excel.programming
Tim Tim is offline
external usenet poster
 
Posts: 408
Default Autofit columns, password protected

Hi there,
So could I insert your code somewhere in between the password protect and
unprotect code and copy in to each sheet?
Could you show me how? I really do need to protect and unprotect these
sheets. Thanks

"ryguy7272" wrote:

Ok, this will auto-fiit the columns A:I for you:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False

Worksheets("Sheet1").Columns("A:I").AutoFit

Application.EnableEvents = True
End Sub

You have to unprotect the sheet to enable this kind of change. If you
auto-unprotect the sheet, there is no point in protecting the sheet. You can
certainly control that with another macro though...from a post back in 2007
by 'JW'

To unprotect the sheet:
Sheets("Sheet2").Unprotect Password:="YourPassword"

To protect the sheet:
Sheets("Sheet2").Protect Password:="YourPassword"

To run a check and proceed accordingly:
Sub thiser()
Dim pw As String
pw = "YourPassword"
With Sheets("Sheet2")
If .ProtectContents = True Then
.Unprotect Password:=pw
Else
.Protect Password:=pw
End If
End With
End Sub

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Tim" wrote:

Hi there,
I have 12 sheets (Deposits) and 12 sheets (Cheques). I want the column to
autofit based on user text input. So for Deposits ( columns G and H ) ....
for Cheques ( columns I and J ). Not sure how to make them autofit and
password protect. Any ideas out there? Thanks very much.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Autofit columns, password protected

When you protect the sheet enable formatting of columns.

Also uncheck select locked cells.

Then users can select and enter text only in the two columns that are
unlocked.

I assume G and H are unlocked so's users can input the text.


Gord Dibben MS Excel MVP

On Mon, 25 Jan 2010 13:37:01 -0800, Tim
wrote:

Hi there,
I have 12 sheets (Deposits) and 12 sheets (Cheques). I want the column to
autofit based on user text input. So for Deposits ( columns G and H ) ....
for Cheques ( columns I and J ). Not sure how to make them autofit and
password protect. Any ideas out there? Thanks very much.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Rows().AutoFit starts a calculation, but Columns().AutoFit doesn't Stefano[_2_] Excel Programming 1 November 30th 09 05:01 PM
Rows().AutoFit starts a calculation, but Columns().AutoFit doesn't Mike H Excel Programming 0 November 25th 09 04:31 PM
Autofit (Columns.EntireColumn.AutoFit) does not work Michiel via OfficeKB.com Excel Discussion (Misc queries) 3 February 10th 09 05:29 PM
Hide / Unhide Columns in Password Protected w/s monir Excel Programming 2 January 12th 08 12:44 AM
how to automate opening a password protected excel file? e.g. a .xls that has a password set in the security tab. Daniel Excel Worksheet Functions 0 June 23rd 05 11:56 PM


All times are GMT +1. The time now is 06:28 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"