Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default excel macro help

Hi,
Maybe someone can help me.
i need to create a marco that preforms the following:
at the beginning all worksheet is locked, but the cells on column A.
1) if data is entered into cell a7 then cell b7 unlocks and if data is
entered to cell b7 cell c7 unlock and so forth for row 1.
the same must apply to all the other rows on the worksheet.
the only cells that are not locked are those on column A from row 7,
and the rows 1-7 which are locked all the time.
thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default excel macro help

Try this idea. Right click sheet tabview codecopy/paste this

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Locked = True Then Exit Sub
ActiveSheet.Unprotect
Target.Offset(, 1).Locked = False
ActiveSheet.Protect
End Sub

--
Don Guillett
SalesAid Software

"Guye" wrote in message
ups.com...
Hi,
Maybe someone can help me.
i need to create a marco that preforms the following:
at the beginning all worksheet is locked, but the cells on column A.
1) if data is entered into cell a7 then cell b7 unlocks and if data is
entered to cell b7 cell c7 unlock and so forth for row 1.
the same must apply to all the other rows on the worksheet.
the only cells that are not locked are those on column A from row 7,
and the rows 1-7 which are locked all the time.
thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default excel macro help

one more thing i completely forgot about,
is it possible to creat the reversible, if i delet the info from the
cell the next cells will be locked

thank
guy

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default excel macro help

hi
How can i activate the previous Sub automaticaly when the file opens.
thanks guy

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default excel macro help

Here is something simple that will work.
The code goes in the worksheet module, not a general module.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row < 7 Then Exit Sub

If Target.Value < "" Then
Me.Unprotect
Target.Offset(0, 1).Locked = False
Me.Protect
End If
End Sub

Mike F
"Guye" wrote in message
ups.com...
Hi,
Maybe someone can help me.
i need to create a marco that preforms the following:
at the beginning all worksheet is locked, but the cells on column A.
1) if data is entered into cell a7 then cell b7 unlocks and if data is
entered to cell b7 cell c7 unlock and so forth for row 1.
the same must apply to all the other rows on the worksheet.
the only cells that are not locked are those on column A from row 7,
and the rows 1-7 which are locked all the time.
thanks





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default excel macro help

Here is the reverse procedure, but it will only work if you clear one cell
at a time from column A only.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row < 7 Then Exit Sub

If Target.Value < "" Then
Me.Unprotect
Target.Offset(0, 1).Locked = False
Me.Protect
End If


If Target.Column < 2 And Target.Value = "" Then
Application.EnableEvents = False
Me.Unprotect
With Target.EntireRow
.Clear
.Locked = True
End With
Target.Locked = False
Me.Protect
Application.EnableEvents = True
End If
End Sub


Mike F
"Guye" wrote in message
oups.com...
one more thing i completely forgot about,
is it possible to creat the reversible, if i delet the info from the
cell the next cells will be locked

thank
guy



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default excel macro help

I am not sure what you mean. This is Worksheet Event code, which means when
any cell content is changed, the code will run.

Mike F
"Guye" wrote in message
oups.com...
hi
How can i activate the previous Sub automaticaly when the file opens.
thanks guy



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default excel macro help

thank Mike,
you have been of great help to me

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default excel macro help

hi
no, its not an event code.
the file is just made to store information.

by the way, the Sub you gave me locks the cells but it also formats
all the rows characteristic such as color etc, etc, and not only
erase the information on the row


  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default excel macro help

The code that Don and I gave you is event code, if pasted where Don said to.
Apparently you did or it would not work right. To fix the cell formats from
being changed when you clear a cell in column A, change .Clear to
..ClearContents.

Mike F
"Guye" wrote in message
oups.com...
hi
no, its not an event code.
the file is just made to store information.

by the way, the Sub you gave me locks the cells but it also formats
all the rows characteristic such as color etc, etc, and not only
erase the information on the row






  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default excel macro help

thanks for the code
it works now perfectly

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
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 3 February 5th 07 08:22 PM
Need syntax for RUNning a Word macro with an argument, called from an Excel macro Steve[_84_] Excel Programming 3 July 6th 06 07:42 PM
translate lotus 1-2-3 macro into excel macro using excel 2000 krutledge0209 Excel Programming 1 November 2nd 04 05:50 PM
Excel Macro Issue Trying to autorun Macro Upon Opening Worksheet wyndman Excel Programming 2 May 25th 04 06:59 PM


All times are GMT +1. The time now is 06:36 PM.

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

About Us

"It's about Microsoft Excel"