How do I lock header rows but allow creation of new rows using AXLSX? - axlsx

If I add sheet protection to my worksheet, and then unlock all but my header rows, it's almost working. But I'm not able to add new rows. I suspect it's because the default style for a worksheet is that cells are locked. What's the incantation to make cells be unlocked by default?

Related

Insert or update cells ([Range]) from one sheet to another

I have a vba code that gets specific range from inputsheet and then pastespecial with xlValue to just copy the values.
However, I want that if the macro runs again, it should update value if already in outputSheet otherwise insert.
what is the best way to do it?
I want to avoid looping cells for performance.
I can modify the existing copy process to include some metadata with the values, like sourceCell.address. but with any metadata, i would still want to avoid loop.
Is there any recommended way of doing this?

A: Hide rows in Excel VBA when target cell contents are deleted

I'm working on a VBA in excel that hides or un-hides rows on other worksheets based on the content of target cell specific drop-down lists. The drop down lists are meant to be dynamic, and users will occasionally change the responses. Everything works well when responses are changed except when a user might delete previously entered content within a target cell with the delete button. If this occurs, the hide/un-hide feature on the other sheets doesn't react.
Is there a line of code I can use to make True/False a hidden row command based on a user simply deleting content in a target cell (or multiple target cells if the user was to try to clear the whole front-end form by deleted content across all the drop down lists in all targeted cells?)?
Thanks in advance for the help!

Sorting on a protected Excel sheet

i have an excel related problem. I already searched older questions but neither of them have a good anwser for the problem.
I want to be able to sort, filter and use pivot tables on a protected sheet. I researched so far that one can not sort on a protected sheet. But is there a way to unlock the sheet for sorting and then lock it again after successful sorting?
thx in adavance
In general, you can choose things to allow when you protect a sheet, such as filtering (when you click on "Protect Sheet", there is a list titled "Allow all users of this worksheet to:").
With sorting, it really depends on whether the cells in the table are locked or not. If not, it works just by allowing it in the protection menu. If some are locked, there is a workaround with
Review (Ribbon) > Allow users to edit ranges
whilst disallowing selection of locked cells. Here you basically add the locked ranges of your table to the "editable" ranges, but at the same time you disallow users to click on them, so that they stay in fact uneditable. But this method does come with its drawbacks, I'm sure you can find more details on google.
About pivot tables, try checking the option "Use pivot table reports" in the list when locking the worksheet.
You'll need to right click on the filter cells > Format cells > Protection tab > untick 'Locked'. Then protect the worksheet tick the options to 'Sort', 'Use Autofilter', 'Use PivotTable reports'. This will allow the user to sort, filter etc but will also allow them to edit the cells directly i.e. not just using the sort button. You could untick the 'Select locked cells' option when you protect the worksheet to prevent this direct editing.

Parameter to allow users to select locked cells?

What's the parameter to allow users to select locked cells? When you manually protect a worksheet there is an option for this, but I can't find it for VBA.
Sorry if this question has been asked but I can't find it with so many overlapping words with other results.
If you mean you that you want to keep certain cells unlocked when the worksheet is protected (so that users may select, edit, etc.) you can use:
Range("A1").Locked = False
Where A1 can be replaced with whichever range of cells you want to leave unlocked when the sheet is protected.
Alternatively, you may be able to accomplish what you need by using:
Worksheets("Sheet1").EnableSelection = xlNoRestrictions
And changing Sheet1 to whichever worksheet you want users to be able to select on.

Copy Excel worksheets, macros, and graphs from one workbook to another, moving links to the new workbook

I have an Excel workbook with a number of features:
One main user-facing sheet
One summary sheet based on the user-facing sheet's data
A number of graphs based on the user-facing sheet's data (as in, the type of graphs with a separate tab for them, rather than objects within a worksheet - I'm not sure if they have a special name or special properties)
A series of 'background' worksheets that calculate the values for the user-facing sheet
A macro to allow the user to sort the user-sheet by any column they wish, which is referenced in the user-facing sheet's Worksheet_SelectionChange event
However, for distribution I'd like to cull the sheets for simplicity (and file size - the entire data query is included on one of the sheets). I still need to calculate the values for the user-facing sheet, but it's only done once per dataset, so that can quite happily be copied as formatting then values.
The trouble, however, is transferring the dependent sheet, graphs and macros across to a new workbook so that instead of referencing the old workbook, they reference the new versions of the sheet. Ideally I'd like to do this with VBA or something, but my Google searches thus far don't seem to have turned up much of relevance.
Does anyone know how to do this?
I'm not sure I entirely understand your question, but what I think that you want to do is to create a new version of your workbook, with less worksheets in it??
To do that in VBA, this code snippet is a good place to start:
Sub Macro1()
ActiveWorkbook.SaveAs Filename:= _
[your path here]\Book2.xls", FileFormat:=xlNormal, _
Sheets("Sheet2").Select
ActiveWindow.SelectedSheets.Delete
End Sub
Creating a copy of the entire workbook, and then deleting what you don't need will make sure that the links do not reference the old workbook.
Once you have created the new workbook, with links intact, it is then pretty easy to remove all the things (calculations, etc.) that you don't need.