Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Fecozisk
 
Posts: n/a
Default Ken Johnson or someone! -- I need some help again!

Hi! and thanks for everything!
do you remember last topic "Help me! Using Excel for Soccer Games" ??
well, i have a problem on it... im using the following:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column 46 Or Target.Row 29 Then
Exit Sub
End If
If Target.Column < 5 Or Target.Row < 3 Then
Exit Sub
End If
Me.Unprotect
Target.Locked = True
Me.Protect
End Sub

with this i have one interval of cells being affected by the macro
perfectly, which is E4:AT29
The problem is that in the same sheet i also need to use another interval,
which is E66:AT91
....and i dont know anything about visual basic... i just copy and paste! how
should i rewrite it?
thanks!


  #2   Report Post  
Posted to microsoft.public.excel.misc
Bryan Hessey
 
Posts: n/a
Default Ken Johnson or someone! -- I need some help again!


Perhaps something like


Code:
--------------------
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
Dim iCol As Integer, iRow As Integer, iLock As Integer

iLock = 0
iCol = Target.Column
iRow = Target.Row

If iCol = 5 And iCol <= 46 And iRow = 3 And iRow <= 29 Then
iLock = 1
Else
If iCol = 5 And iCol <= 46 And iRow = 66 And iRow <= 91 Then
iLock = 1
End If
End If

If iLock = 1 Then
Me.Unprotect
Target.Locked = True
Me.Protect
End If

End Sub
--------------------

will help

--

Fecozisk Wrote:
Hi! and thanks for everything!
do you remember last topic "Help me! Using Excel for Soccer Games"
??
well, i have a problem on it... im using the following:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column 46 Or Target.Row 29 Then
Exit Sub
End If
If Target.Column < 5 Or Target.Row < 3 Then
Exit Sub
End If
Me.Unprotect
Target.Locked = True
Me.Protect
End Sub

with this i have one interval of cells being affected by the macro
perfectly, which is E4:AT29
The problem is that in the same sheet i also need to use another
interval,
which is E66:AT91
....and i dont know anything about visual basic... i just copy and
paste! how
should i rewrite it?
thanks!



--
Bryan Hessey
------------------------------------------------------------------------
Bryan Hessey's Profile: http://www.excelforum.com/member.php...o&userid=21059
View this thread: http://www.excelforum.com/showthread...hreadid=537547

  #3   Report Post  
Posted to microsoft.public.excel.misc
Stefan
 
Posts: n/a
Default Ken Johnson or someone! -- I need some help again!

"Fecozisk" wrote:

Hi! and thanks for everything!
do you remember last topic "Help me! Using Excel for Soccer Games" ??
well, i have a problem on it... im using the following:


The problem is that in the same sheet i also need to use another interval,
which is E66:AT91


If you have multiple ranges it's best to determine the valid fields instead
of the invalid ones:

Private Sub Worksheet_Change(ByVal Target As Range)
cm = Target.Column
rw = Target.Row
If (cm = 5 And cm <= 46) And ((rw = 4 And rw <= 29) Or (rw = 66 And rw
<= 91)) Then
Me.Unprotect
Target.Locked = True
Me.Protect
End If
End Sub


In your case the columns are the same so you can test the column-range in
one time.

--
greetings from Belgium
Stefan.
  #4   Report Post  
Posted to microsoft.public.excel.misc
Ken Johnson
 
Posts: n/a
Default Ken Johnson or someone! -- I need some help again!

Hi Fecozisk,

This works too...

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Range("E4:AT29,E66:AT91"), Target) Is Nothing Then
Exit Sub
End If
If Target.Column < 5 Or Target.Row < 3 Then
Exit Sub
End If
Me.Unprotect
Target.Locked = True
Me.Protect
End Sub


Ken Johnson

  #5   Report Post  
Posted to microsoft.public.excel.misc
Ken Johnson
 
Posts: n/a
Default Ken Johnson or someone! -- I need some help again!

Hi Fecozisk,

Sorry, I should've tidied it up a bit more..

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Range("E4:AT29,E66:AT91"), Target) Is Nothing Then
Exit Sub
End If
Me.Unprotect
Target.Locked = True
Me.Protect
End Sub

Ken Johnson



  #6   Report Post  
Posted to microsoft.public.excel.misc
Fecozisk
 
Posts: n/a
Default Ken Johnson or someone! -- I need some help again!

Thanks all you guys! 100% solved!

"Ken Johnson" escreveu:

Hi Fecozisk,

Sorry, I should've tidied it up a bit more..

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Range("E4:AT29,E66:AT91"), Target) Is Nothing Then
Exit Sub
End If
Me.Unprotect
Target.Locked = True
Me.Protect
End Sub

Ken Johnson


  #7   Report Post  
Posted to microsoft.public.excel.misc
Ken Johnson
 
Posts: n/a
Default Ken Johnson or someone! -- I need some help again!

Hi Fecozisk,

You're always welcome.

Thanks for the feedback.

Ken Johnson

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
Statistics/Charting Question - Please Help!! elfmajesty Excel Discussion (Misc queries) 2 January 13th 06 07:59 PM
Copying different repeating entries down a column Access Joe Excel Discussion (Misc queries) 2 January 13th 06 02:34 PM
Johnson BillyJ Excel Discussion (Misc queries) 0 October 27th 05 09:17 PM
formula to fill text with multiple conditions jerry Excel Discussion (Misc queries) 2 September 8th 05 11:26 PM
TemplateWizard Excel 2003 johnson Excel Discussion (Misc queries) 6 January 30th 05 01:40 PM


All times are GMT +1. The time now is 10:00 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"