Link to home
Start Free TrialLog in
Avatar of Chrisneilhopkins
Chrisneilhopkins

asked on

linking data in Excel from another Excel workbook

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?
Avatar of Ingeborg Hawighorst (Microsoft MVP / EE MVE)
Ingeborg Hawighorst (Microsoft MVP / EE MVE)
Flag of New Zealand image

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
When Parameters is updated   (unlocked, updated, and locked), the Budget values will be updated.
Avatar of Chrisneilhopkins
Chrisneilhopkins

ASKER

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
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

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

You could update the range and password in unProtect_one_cell_in_all_Worksheet and Protect_one_cell_in_all_Worksheet.
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.
ASKER CERTIFIED SOLUTION
Avatar of Member_2_6169280
Member_2_6169280
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.