Solved

linking data in Excel from another Excel workbook

Posted on 2011-03-07
11
159 Views
Last Modified: 2012-05-11
Hi,
Is there a way of linking cell properties in excel.
I want to link PROTECTION from an excel document.
i.e.
on PARAMETERS.xls, if i have a cell 'Total Cost' which has been formatted and 'LOCKED'.
Then on BUDGET.xls, i have linked a cell to the above 'Total Cost'. I know it would copy the text, but i am wondering if it could also copy the PROTECTION too.
That way if i need to UNPROTECT that cell, i would only need to unprotect the PARAMETERS.xls which would unprotect the BUDGET.xls automatically.
The reason for this is because the BUDGET.xls will be used by 115 customers and contains 52 worksheets (1 for each week), which is almost 6000 cells in total .So instead of UNPROTECTING 6000 cells, i would only need to unprotect 1 cell.
Normally i would just create a macro and run the macro for all customers, but this still takes time to do.
Does anyone know if this is possible?
0
Comment
Question by:Chrisneilhopkins
11 Comments
 
LVL 50

Expert Comment

by:Ingeborg Hawighorst
ID: 35055335
Hello,

if you link to a cell in another workbook, you will only be able to retrieve the cell value. Any other properties like formatting, including the "locked" setting will not be carried over with a linked cell.

So, if you can do it with a macro, that's the way to go.

cheers, teylyn
0
 
LVL 18

Expert Comment

by:Richard Daneke
ID: 35057896
When Parameters is updated   (unlocked, updated, and locked), the Budget values will be updated.
0
 

Author Comment

by:Chrisneilhopkins
ID: 35058586
Thanks, but its not the values being updated that i'm querying. Although i want the values to be updates, i would also want the option to unprotect and protect on mass. rather than do each of the customers spreadsheets individually.
I create new spreadsheets every financial year, and for the last 4 years i have had to go through each of the spreadsheets after the year had been started to make corrections to mistakes that i have made when creating them.
This year i have decided to make things a bit easier by creating a PARAMETERS sheet (which i can use for changing field names and values), but if i wanted to UNPROTECT or PROTECT a field on mass then that would save me a huge amount of time.
Hopefully i woill not have to use them, but i'm sure i will make a mistake somewhere along the line!
:) thanks
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 6

Expert Comment

by:royhsiao
ID: 35062241
here is a way to protect and unprotect worksheet in vba


Sub Protect_all_Worksheet()
Dim wksht As Worksheet
Dim w_i As Long
Dim wkshtnames()
w_i = 0

''count the worksheet
For Each wksht In ActiveWorkbook.Worksheets
    w_i = w_i + 1
    ReDim Preserve wkshtnames(1 To w_i)
    wkshtnames(w_i) = wksht.Name
Next wksht

''showt the sheet's name
    For w_i = LBound(wkshtnames) To UBound(wkshtnames)
          ''update the password in ""
        Sheets(wkshtnames(w_i)).Protect Password:=""
    Next w_i

End Sub

Sub unProtect_all_Worksheet()
Dim wksht As Worksheet
Dim w_i As Long
Dim wkshtnames()
w_i = 0

''count the worksheet
For Each wksht In ActiveWorkbook.Worksheets
    w_i = w_i + 1
    ReDim Preserve wkshtnames(1 To w_i)
    wkshtnames(w_i) = wksht.Name
Next wksht

''showt the sheet's name
    For w_i = LBound(wkshtnames) To UBound(wkshtnames)
        ''update the password in ""
        Sheets(wkshtnames(w_i)).Unprotect Password:=""
    Next w_i

End Sub

Open in new window

0
 
LVL 6

Expert Comment

by:royhsiao
ID: 35062651
Here is the way to protect or unprotect a range in all worksheet in vba
''//Created by RoyHsiao 3/7/2011
Sub unProtect_one_cell_in_all_Worksheet()
Dim wksht As Worksheet
Dim w_i As Long
Dim wkshtnames()
w_i = 0

''count the worksheet
For Each wksht In ActiveWorkbook.Worksheets
    w_i = w_i + 1
    ReDim Preserve wkshtnames(1 To w_i)
    wkshtnames(w_i) = wksht.Name
Next wksht

''showt the sheet's name
    For w_i = LBound(wkshtnames) To UBound(wkshtnames)
        ''update the password in ""
        Sheets(wkshtnames(w_i)).Unprotect Password:=""
        Sheets(wkshtnames(w_i)).Select
        Range("A1").Select
        Selection.Locked = False
        Selection.FormulaHidden = False
        Sheets(wkshtnames(w_i)).Protect Password:=""
    Next w_i
End Sub
''//Created by RoyHsiao 3/7/2011
Sub Protect_one_cell_in_all_Worksheet()
Dim wksht As Worksheet
Dim w_i As Long
Dim wkshtnames()
w_i = 0

''count the worksheet
For Each wksht In ActiveWorkbook.Worksheets
    w_i = w_i + 1
    ReDim Preserve wkshtnames(1 To w_i)
    wkshtnames(w_i) = wksht.Name
Next wksht

''showt the sheet's name
    For w_i = LBound(wkshtnames) To UBound(wkshtnames)
        ''update the password in ""
        Sheets(wkshtnames(w_i)).Unprotect Password:=""
        Sheets(wkshtnames(w_i)).Select
        Range("A1").Select
        Selection.Locked = True
        Selection.FormulaHidden = False
        Sheets(wkshtnames(w_i)).Protect Password:=""
    Next w_i
End Sub

Open in new window

0
 
LVL 6

Expert Comment

by:royhsiao
ID: 35062665
You could update the range and password in unProtect_one_cell_in_all_Worksheet and Protect_one_cell_in_all_Worksheet.
0
 
LVL 18

Expert Comment

by:Richard Daneke
ID: 35062686
You could use a macro to unprotect the worksheet and another macro to protect the worksheet.

This method makes the current lock value meaningless.

Also, note that Excel 2007 and 2010 can use cell styles that can set or reset protection on unlocked worksheets.
0
 
LVL 6

Accepted Solution

by:
royhsiao earned 500 total points
ID: 35343745
Hi Chrisneilhopkins,

I provided the following code in the post id: 35062651. I hope it will help.
''//Created by RoyHsiao 3/7/2011
Sub unProtect_one_cell_in_all_Worksheet()
Dim wksht As Worksheet
Dim w_i As Long
Dim wkshtnames()
w_i = 0

''count the worksheet
For Each wksht In ActiveWorkbook.Worksheets
    w_i = w_i + 1
    ReDim Preserve wkshtnames(1 To w_i)
    wkshtnames(w_i) = wksht.Name
Next wksht

''showt the sheet's name
    For w_i = LBound(wkshtnames) To UBound(wkshtnames)
        ''update the password in ""
        Sheets(wkshtnames(w_i)).Unprotect Password:=""
        Sheets(wkshtnames(w_i)).Select
        Range("A1").Select
        Selection.Locked = False
        Selection.FormulaHidden = False
        Sheets(wkshtnames(w_i)).Protect Password:=""
    Next w_i
End Sub
''//Created by RoyHsiao 3/7/2011
Sub Protect_one_cell_in_all_Worksheet()
Dim wksht As Worksheet
Dim w_i As Long
Dim wkshtnames()
w_i = 0

''count the worksheet
For Each wksht In ActiveWorkbook.Worksheets
    w_i = w_i + 1
    ReDim Preserve wkshtnames(1 To w_i)
    wkshtnames(w_i) = wksht.Name
Next wksht

''showt the sheet's name
    For w_i = LBound(wkshtnames) To UBound(wkshtnames)
        ''update the password in ""
        Sheets(wkshtnames(w_i)).Unprotect Password:=""
        Sheets(wkshtnames(w_i)).Select
        Range("A1").Select
        Selection.Locked = True
        Selection.FormulaHidden = False
        Sheets(wkshtnames(w_i)).Protect Password:=""
    Next w_i
End Sub

Open in new window

0
 
LVL 24

Expert Comment

by:broomee9
ID: 35783891
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question