473,378 Members | 1,309 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Repete this code for every row

Hi, I have this code to lock some cells if date has passed:

Expand|Select|Wrap|Line Numbers
  1. If [MARCADORES!E3] <= Date Then
  2. ActiveSheet.Unprotect ("mundial")
  3. ActiveSheet.Range("MARCADORES!I3:T3").Locked = True
  4. ActiveSheet.Protect ("mundial")
  5. Else
  6. ActiveSheet.Unprotect ("mundial")
  7. ActiveSheet.Range("MARCADORES!I3:T3").Locked = False
  8. ActiveSheet.Protect ("mundial")
  9. End If
How can i do to repeat this in every row??

For :
[MARCADORES!E4] - ActiveSheet.Range("MARCADORES!I4:T4")
[MARCADORES!E5] - ActiveSheet.Range("MARCADORES!I5:T5")
and so on...........
May 9 '10 #1
1 1029
dsatino
393 256MB
All my VBA is in Access so I'm just assuming that a lot of the functionality is the same....

You need to set up a variable and Loop statement

Public Sub Test()
dim x as integer
dim strVar as string

x=1

Do
strVar="[MARCADORES!E" & x & "]"

If strVar <= Date Then
ActiveSheet.Unprotect ("mundial")
ActiveSheet.Range("MARCADORES!I3:T3").Locked = True
ActiveSheet.Protect ("mundial")
Else
ActiveSheet.Unprotect ("mundial")
ActiveSheet.Range("MARCADORES!I3:T3").Locked = False
ActiveSheet.Protect ("mundial")
End If

x=x+1
Loop
End Sub

You'll have to modify this to Excel specifically, but hopefully this gives you the general idea. Also the Do/Loop as it is above will pretty much run forever so you'll to change it to a Do Until/Loop in which you've set the Until to max number.
May 10 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: 42zeros | last post by:
I would like a function to be executed every x often. I was just wondering how to pass the following code correctly. my object t just doesn't know what checkMail is. How can I tell it that...
9
by: Markus Minichmayr | last post by:
Hello! Does anyone know a free tool to collect source code metrics like lines of code, no. of classes, etc.? Thanks Markus
3
by: eiselekd | last post by:
Does anyone know about a code snippet that can be used to output a backtrace just like gdb's "backtrace" command does. One that can be called on a segmentation fault. (without resolving symbol...
192
by: Vortex Soft | last post by:
http://www.junglecreatures.com/ Try it and tell me what's happenning in the Microsoft Corporation. Notes: VB, C# are CLS compliant
8
by: Scott M | last post by:
I have a procedure in my Dispose method that records my application was closed in a database. However, when I kill a process or an unhandled exception occurs this does not seem to run. Is there...
5
by: MOHAN6491 | last post by:
Dear Members, In our systems, for every pages, when I view the source code, every page is appended with some <script language=vbscript>,,,,,,etc,,, some funny ugly characters appears ........
6
by: coldwind2010 | last post by:
Hi! I want to post a form to a page,and get the output of the page. But the post value includes a authentication code which is 13 figures and change every time. I use curl fuction to do so. I...
2
by: ioshonowo | last post by:
Hello. Could someone give me the command that will allow my batch program to execute an iteration of a for loop then wait 5 minutes and execute another iteration. I have tried wait and sleep but...
4
by: Don Quijote de Nicaragua | last post by:
Hi everyone, I have a code which should be implemented in my site every 24 hours, I have no idea how can do, greatly appreciate any suggestions. Thank You. spanish: Hola a todos, tengo un...
4
by: qwedster | last post by:
Folks, How to the next value of identity(1,1) before insert? SELECT IDENT_CURRENT('ExampleTable') + IDENT_INCR('ExampleTable'); --does not work when the table is empty! USE GO
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.