Select a range based on system date

Part 1

I have a spreadsheet that I want to open protected (locked). However,
I want to unlock a specific range for data entry based on the day of
the actual system date.

For example if today is 11/5/08 then we want to unlock row 5,
specifically cells B5:I5.

I have experimented with several functions, which return the desired
results, but I am not skilled enough to place them into a well-written
VBA subroutine.

Please note the following function examples that return the start and
ending cells of the desired range.

=ADDRESS(DAY(NOW()),2) this will display the start cell of the range
(B5) and=ADDRESS(DAY(NOW()),9) will display the last cell in the range
(I5).

If anyone could assist with the writing of a subroutine that would
select the whole range, for example;

ADDRESS(DAY(NOW()),2).ADDRESS(DAY(NOW()),9).Select

That would be the first step to my solution.

Part 2

Tying it all together...

Once the range can be selected based on the system date, through code,
then the next task is to either unlock that range for editing or
better yet, utilize the menu command Tools, Protection, Protect and
Share Workbook and should read menu command Tools, Protection, Allow
Users to Edit Ranges

So we can allow specific users based on their Active Directory Account
to edit a particular range.

However, at a minimum, opening the sheet unlocked (protected) and
saving it locked (protected) would work.

Thanks in advance for staying up at night working on this.


0
tewsuave (1)
12/3/2008 10:28:33 PM
excel 39879 articles. 2 followers. Follow

3 Replies
319 Views

Similar Articles

[PageSpeed] 51

Sub UnlockUm()
Dim s1 As String
Dim s2 As String
s1 = Evaluate("ADDRESS(DAY(NOW()),2)")
s2 = Evaluate("ADDRESS(DAY(NOW()),9)")
Range(s1 & ":" & s2).Locked = False
End Sub

-- 
Gary''s Student - gsnu2007k


"tewsuave@gmail.com" wrote:

> Part 1
> 
> I have a spreadsheet that I want to open protected (locked). However,
> I want to unlock a specific range for data entry based on the day of
> the actual system date.
> 
> For example if today is 11/5/08 then we want to unlock row 5,
> specifically cells B5:I5.
> 
> I have experimented with several functions, which return the desired
> results, but I am not skilled enough to place them into a well-written
> VBA subroutine.
> 
> Please note the following function examples that return the start and
> ending cells of the desired range.
> 
> =ADDRESS(DAY(NOW()),2) this will display the start cell of the range
> (B5) and=ADDRESS(DAY(NOW()),9) will display the last cell in the range
> (I5).
> 
> If anyone could assist with the writing of a subroutine that would
> select the whole range, for example;
> 
> ADDRESS(DAY(NOW()),2).ADDRESS(DAY(NOW()),9).Select
> 
> That would be the first step to my solution.
> 
> Part 2
> 
> Tying it all together...
> 
> Once the range can be selected based on the system date, through code,
> then the next task is to either unlock that range for editing or
> better yet, utilize the menu command Tools, Protection, Protect and
> Share Workbook and should read menu command Tools, Protection, Allow
> Users to Edit Ranges
> 
> So we can allow specific users based on their Active Directory Account
> to edit a particular range.
> 
> However, at a minimum, opening the sheet unlocked (protected) and
> saving it locked (protected) would work.
> 
> Thanks in advance for staying up at night working on this.
> 
> 
> 
0
GarysStudent (1572)
12/4/2008 1:22:00 AM
Option Explicit
Sub testme()
    With ActiveSheet
        .Unprotect Password:="topsecret"
        .Cells(Day(Date), "B").Resize(1, 8).Locked = False
        .Protect Password:="topsecret"
    End With
End Sub

But this won't work if the workbook is shared.  

You can't change the protection of a worksheet in a shared workbook.

tewsuave@gmail.com wrote:
> 
> Part 1
> 
> I have a spreadsheet that I want to open protected (locked). However,
> I want to unlock a specific range for data entry based on the day of
> the actual system date.
> 
> For example if today is 11/5/08 then we want to unlock row 5,
> specifically cells B5:I5.
> 
> I have experimented with several functions, which return the desired
> results, but I am not skilled enough to place them into a well-written
> VBA subroutine.
> 
> Please note the following function examples that return the start and
> ending cells of the desired range.
> 
> =ADDRESS(DAY(NOW()),2) this will display the start cell of the range
> (B5) and=ADDRESS(DAY(NOW()),9) will display the last cell in the range
> (I5).
> 
> If anyone could assist with the writing of a subroutine that would
> select the whole range, for example;
> 
> ADDRESS(DAY(NOW()),2).ADDRESS(DAY(NOW()),9).Select
> 
> That would be the first step to my solution.
> 
> Part 2
> 
> Tying it all together...
> 
> Once the range can be selected based on the system date, through code,
> then the next task is to either unlock that range for editing or
> better yet, utilize the menu command Tools, Protection, Protect and
> Share Workbook and should read menu command Tools, Protection, Allow
> Users to Edit Ranges
> 
> So we can allow specific users based on their Active Directory Account
> to edit a particular range.
> 
> However, at a minimum, opening the sheet unlocked (protected) and
> saving it locked (protected) would work.
> 
> Thanks in advance for staying up at night working on this.

-- 

Dave Peterson
0
petersod (12004)
12/4/2008 2:06:38 AM
I think this might be a simpler way to code it...

Sub UnlockUm()
  Range(Cells(Day(Now), 2), Cells(Day(Now), 9)).Locked =3D False
End Sub

--=20
Rick (MVP - Excel)


"Gary''s Student" <GarysStudent@discussions.microsoft.com> wrote in =
message news:7A833B20-FF3F-48D3-8841-56D237FA0069@microsoft.com...
> Sub UnlockUm()
> Dim s1 As String
> Dim s2 As String
> s1 =3D Evaluate("ADDRESS(DAY(NOW()),2)")
> s2 =3D Evaluate("ADDRESS(DAY(NOW()),9)")
> Range(s1 & ":" & s2).Locked =3D False
> End Sub
>=20
> --=20
> Gary''s Student - gsnu2007k
>=20
>=20
> "tewsuave@gmail.com" wrote:
>=20
>> Part 1
>>=20
>> I have a spreadsheet that I want to open protected (locked). However,
>> I want to unlock a specific range for data entry based on the day of
>> the actual system date.
>>=20
>> For example if today is 11/5/08 then we want to unlock row 5,
>> specifically cells B5:I5.
>>=20
>> I have experimented with several functions, which return the desired
>> results, but I am not skilled enough to place them into a =
well-written
>> VBA subroutine.
>>=20
>> Please note the following function examples that return the start and
>> ending cells of the desired range.
>>=20
>> =3DADDRESS(DAY(NOW()),2) this will display the start cell of the =
range
>> (B5) and=3DADDRESS(DAY(NOW()),9) will display the last cell in the =
range
>> (I5).
>>=20
>> If anyone could assist with the writing of a subroutine that would
>> select the whole range, for example;
>>=20
>> ADDRESS(DAY(NOW()),2).ADDRESS(DAY(NOW()),9).Select
>>=20
>> That would be the first step to my solution.
>>=20
>> Part 2
>>=20
>> Tying it all together...
>>=20
>> Once the range can be selected based on the system date, through =
code,
>> then the next task is to either unlock that range for editing or
>> better yet, utilize the menu command Tools, Protection, Protect and
>> Share Workbook and should read menu command Tools, Protection, Allow
>> Users to Edit Ranges
>>=20
>> So we can allow specific users based on their Active Directory =
Account
>> to edit a particular range.
>>=20
>> However, at a minimum, opening the sheet unlocked (protected) and
>> saving it locked (protected) would work.
>>=20
>> Thanks in advance for staying up at night working on this.
>>=20
>>=20
>>
0
12/4/2008 2:54:49 AM
Reply:

Similar Artilces:

Combo box list selection based on earlier selection by user
HI, I have a form that has a combo box 1 (Product) that reads a the Product table and has a unique id attached to each product (RO#). There is a second combo box 2 that is RO#. Now what I would like to do is when a user selects a Product in combo box 1, the system should lookup the Product selected from combo box 1 and upload the corresponding RO# in the combo box 2 list. Now I am using both combo boxes as Unbound and in the combo box 2 I have the two columns Product and RO# - in the Criteria row of RO# I have the following: Like IIf([Forms]![xa_f_lookup]![RO#]=" ",[Forms]![x...

Run report on multi selected records.
I try to make a report for a custom entity that works like the Account Summary: let's say that it's Customer's Inquiry Summary for entity Customer's Inquiry I made the report so that I'm able to run the report on Customer's Inquiry Form. But when I select multi records in the list of Customer's Inquiry and run report, only one record is show in one page of the the report. I would like to have the selected records appear in the report with each record on each page. How can I do this? ...

Query-based list w/1 Exception
I've created a query based distribtuion list which works fine yet out of the 1000 or so mailboxes it gives me I'd like to exclude 10. Is there a way? (Basically I have checked only "Users with Exchange mailbox") Make those 10 recipients members of a distribution group, and add the following to the query: (&(your current query)(!memberOf=distinguished Name of the distribution group)) Alternatively, if there's a common value of a particular attribute like location/city/department, et al, use that to exclude them. -- Bharat Suneja MVP - Exchange www.zenprise.com ...

Can't select objects in Excel 2007
I'm trying to create a form in Excel 2007, and although I can manipulate, copy & paste controls (check boxes, etc) I can't select multiple objects to align them, etc. I've checked on-line help (and have followed the instructions), and other websites, but no one seems to have indicated a problem. It is extremely cumbersome and I need a solution. Any ideas? Thanks in advance, Jim Berglund I know this is about a year too late, but it may help others who have stumbled across this page looking for similar help. On the Home tab, in the Editing group, click Find & Select....

Function to multiple ranges
Which function may be used with multiple ranges? Commonly used "lookups", "index" and "match" don't seem to work. Is there a trick in multiple ranges? Tomek Polak Some functions work, others don't. INDEX has a 4th argument that allows you to specify the area (which of the multiple ranges). The lookup and match functions require a single contiguous block of cells. On Wed, 29 Oct 2003 14:19:08 +0100, "Tomek" <tpolak@poczta.onet.pl> wrote: >Which function may be used with multiple ranges? > >Commonly used "lookups",...

Lot Selection not Showing when I select PO on Receiving Entry
Usually, the Lot selection screen would pop up when I select a PO at the Line Detail of the Receivings Entry, now it does not! And GP will let items post without a lot number! It seems as if a setting has changed. Any ideas anyone? Any help is appreciated. Thanks, R Are you sure the item is marked to track lots? This wiould be set item by item on the Item Maintenance Options window. -- Richard L. Whaley Author / Consultant / MVP 2006-2008 Documentation for Software Users Get our Free Tips and Tricks Newsletter and check out our books at http://www.AccoladePublications.com &q...

Select contact then hangs
Hi, please help. I have a user that when she selects a contact using To: in a new email, after selecting 2, it closes outlook??. Spec is W2kSP4\office2k with all windows updates and office updates installed. Profile has been deleted and re-created, plus i have set up personal folders and moved contacts into there, and set that folder as a default, but makes no difference. Please help. ...

Selecting rows from various sheets
Hi all, I have several sheets with a few columns in each. One colum in each sheet has a unique value. Most of these unique values are th same in each sheet but not all. Is there any way that I can set up new sheet that will have the unique value in column 1 and th corresponding column values frommeach sheet beside it. For example Sheet 1 aa 1 1 1 bb 2 2 2 cc 3 3 3 Sheet 2 aa 4 4 cc 5 5 Result aa 1 1 1 4 4 bb 2 2 2 cc 3 3 3 5 5 Thanks alot, Sha -- sha ----------------------------------------------------------------------- shav's Profile: http...

select text in Calendar
I'm working on a calendar in Publisher. I'm adding text into a cell by spacing down 1 point, then typing in 8 points. Doing fine until April. At that time, I can only select cells (whole days). It will not let me select the text. Help is no help. Any hints out there. Did I accidentally select something to do this? Bonnie Have you added a picture to the cell or a shape? If you have send it to the back, make the cell no fill and try again. -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "GoBonnieGo" <GoB...

SOP Actual Ship Date
In SOP setup, we do not use a Separate Fulfillment process. So, I'm assuming the Actual Ship date defaults from either the system date or the order date on the date the order is created (because it's also fulfilled on that date). Is there any way that we can have the Actual Ship date default to the Invoice date at the time the order is transferred to an invoice? We're trying to get a SmartList that shows (by item) Order Date AND Actual Ship Date/Invoice Date. Is this possible some other way without SmartList Builder? Elaine, 1. Is there any way that we can h...

x-axis range
How do I get the x-axis to be a range of "values" instead of "categories"? I am trying to do a line chart with values over a % range, but I do not have values evenly spaced over the entire range (The chart is asymptotic and I only need to see values from 0 to 40 or so) e.g.: X Y 0.5% 28.8% 1% 44.8% 2% 62.2% 5% 80.9% 10% 89.9% 15% 93.4% 20% 95.3% 35% 97.7% I get the X axis evenly spaced in 8 categories. Seems like older versions of Excel (I am using Office XP/2002) allowed me to set the range and divisions within the range. How do I handle this now? ...

macro to filter data based on selected data
Hi, I am looking for a macro that requests input of a reference code and then a date and then filters the data in my spreadsheet based on this criteria. I am using excel 2007. Any help with this will be greatly appreciated. You can probably record a macro while doing it manually and then clean it up and add input boxes to ask the question or input your variable in a cell and use that. If all else fails, If desired, send your file to my address below. I will only look if: 1. You send a copy of this message on an inserted sheet 2. You give me the newsgroup and the ...

Date formula needed
Hi I need a couple of date formulas for invoices recieved, eg. invoice date is 14/03/2010, payment terms are end of month following. so i need excel to calculate that the due date is in this case 1/05/2010 is the due date. Try =DATE(YEAR(A1),MONTH(A1)+2,1) -- Jacob (MVP - Excel) "d7" wrote: > Hi I need a couple of date formulas for invoices recieved, eg. invoice date > is 14/03/2010, payment terms are end of month following. so i need excel to > calculate that the due date is in this case 1/05/2010 is the due date. > > > Unless ...

Link select with a blast
I have Win 7 Home Premium, x64. Quite often, when I select a link, a mouse pointer changes to a palm with a blast. I understand, the palm is the standard mouse pointer for link select, but what is the blast? What it indicates? -- Ilya Zeldes Fort Myers, Florida Hi Ilya, I suspect that this is being caused by a tracking program. Run something like Ad-Aware and see if it indicates a tracking company. If so, you can delete it, however, it might prevent you from accessing that particular website. Dave "Ilya Zeldes" wrote in message news:7A6FF9B1-5512-44...

How do I add different ranges in a column together?
I have a large column of numbers and need to select random numbers that I need to total. Rather than adidng one cell at a time. How do I add multiple ranges within the column together? Thank you If they're ranges (as in groups of consecutive cells) you can use SUM, as in =sum(a1:a5,a20:a43, ... ). If they're cells that are selected based on the value of some other cell in the same row, you can use sumif: =sumif(b:b,"Selection",a:a) would add the values in column A of the rows where column B is equal to "Selection". If it's really pretty random, I'...

Stop named ranges being copied
I want to copy a worksheet from one workbook to another. But I do not want to copy the named ranges associated with the first workbook to the second. How do I prevent named ranges being copied when I move sheets. >>How do I prevent named ranges being copied when I move sheets. You can't. A named range is just as much a part of a sheet as anything else. Delete the name(s) after you copy a sheet. -- Jim <bmatheson@gmail.com> wrote in message news:1183722346.818571.213860@q75g2000hsh.googlegroups.com... >I want to copy a worksheet from one workbook to another. > >...

Counting number of records based on criteria
Hello, (Try again to get the question in the google-groups. Perhaps not pushed on the send button). For counting records as expression in a report in ms.access I'm using =count(*) which shows all records. Now I also want to know how many of them has registered a specific data in a specific field. I'm trying to use =count([Field1]="999") to count how many of the selection reported has registered data 999. This option isn't work. Can somebody give me the correct solution. thanks, Johan The 999 needs to go in the criteria for the query driving the...

Problem with date
Hi, I just converted my adp project from Access 2000 to Access 2003. In the 2000 version the date written on the SQL server are OK (mm/dd/yyyy). I use the Access 2000 in French and the SQL server is version 7 in English, and the date is ok on the SQL server. After the conversion the date on the SQL server is dd/mm/yyyy. I used Access 2003 in French and the same sql server that I used with the 2000 version. The regional paramater are the same, English (USA), but my workstation is a Windows French 2000 . The command that insert the data in the sql server is an INSERT INTO with a variable, ...

Select Case in a Change Event
Hi, I am trying to use a worksheet Change Event to trap changes to specific columns. depending on which column is chnaged by the user, the value in another ciolumn will be altered; so, changes in either column O or P will update column Q, changes in either column T or U will update column V and changes in column Z or AA will update column AB. What I can't figure out is the Select Case bit (where I've got the shouted question below). Here's what I've put together, any comments would be much appreciated. Private Sub Worksheet_Change(ByVal Target As Range) ...

Campaign Activity
Hi, When I create an e-mail Campaign Activity against a campaign that has a valid marketing list where all members have valid e-mail addresses, Select Distribute, and close the campaign, the Status Reason changes to System Aborted and no e-mails are created. I checked the Bulk E-mail service and it is running. I have System Administrator rights so I don't think this is a security rights issue. Does anyone have any ideas? Thank you, Donna Donna, I had a similar problem when I tried Quick Campaigns, regular campaigns or the bulk email service - they all system aborted but afte...

Select Records based another table...
This may be very elementary, but i can't wrap my brain around it. I have tried to dummy it down as much as i can for myself, with plans of adapting it into something working. I have three tables that look like the following: Tbl 1: ProdID A B C 1 $1 $2 $3 2 $4 $5 $6 3 $7 $8 $9 Tbl 2: RmNum ProdID 1 3 1 2 2 1 2 2 Tbl 3: RmNum Style 1 A 2 C Relationships are: [tbl1 ProdID] ------ [tbl2 ProdID] [tbl2 RmNum] ...

SQL: Summing By Date Continuously?
Two tables: tblPaymentAccrualDaily SecID PayDate PayAmount 003 01/01/2007 123.97 004 01/01/2007 4250.63 003 01/02/2007 123.43 003 01/03 2007 120.45 003 01/04/2007 119.20 003 01/05/2007 130.44 ...and so on for each and every day tblPaymentSchedule SecID PayDate 003 01/03/2007 003 02/03/2007 003 03/05/2007 003 04/03/2007 What I want to do is present, for a given SecID, the total daily accruals from tblPaymentSchedule.PayDate to the next (actually, the day after one PayDate to the next...

How to freeze a range in excel 2003and 2007
I want to freeze a group of cells in excel 2007 but when I click on the freeze panes, top row or first column: nothing happens- I mean it scrolls up and down. Also is there anyway I can print an excel worksheet which is several pages long and still have the headings (which is in say the first 3 rows ie A1 - E1 down to A3 - E3) printed on each page? Lets say the headings are on only page 1 but i want it to be on page 2,3,4 to the last page when printed. Can freezing do that? Thanks. Hi In order the Freeze Panes, your cursor needs to be one cell below, and one cell the the right of the Row an...

Multi-Select List Box Does Not Retain Selected Items
I created an Outlook Form in 2003. But when I select items in the list box they do not remain select when I select another control on the form. Any suggestions? Did you bind the list box to a keywords field? -- Sue Mosher, Outlook MVP Author of Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "kaykay" <anonymous@discussions.microsoft.com> wrote in message news:276dd01c4638d$bd5af590$a501280a@phx.gbl... > I created an Outlook Form in 2003. But when I select > items i...

excel to powerpoint- misalignment of ranges
I have an excel charts which i then paste on powerpoint using the code from Jon Peltier's website. On most charts this works terrific. On some of my charts, in excel I previously copyied a range and pasted it inside the chart. When these charts are pasted into powerpoint the segment which was pasted as a range, becomes misaligned and slides to the left. any solutions would be appreicated. thks ken ...