Solved

linking data in Excel from another Excel workbook

Posted on 2011-03-07
11
160 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 19

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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 19

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

733 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