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

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!

Related

Add A Row - Not adding a row to bottom when previous rows are hidden

I have an order form (hosted by Jotform.com) that's connected to a Google Sheet via the API through a company called Integromat.com. Everything has worked great for years but I received an email from Integromat.com on Friday that we were using a legacy version of the Google Sheets module and we needed to update before that legacy version stopped working.
I updated our modules (which I assume just updates the Google Sheets API?) and now I'm encountering a problem that I'm not sure how to fix. Integromat is claiming that "Unfortunately this behavior comes directly from Google Sheet's and we can't avoid it." but I question that.
My problem: The sheet that receives the order form data is updated properly so long as the very last row of filled data is unhidden. But we hide rows as orders are completed and if all the rows are hidden and a new order comes in a row is added at the top of the Sheet (row 2 since we have a header that's never hidden in row 1) which in turn throws off several other Sheets that are connected to the order sheet.
Before the update, the add a row function didn't care if rows were hidden or not. But since the update it's like it can't tell if data is contained in hidden rows or not and just proceeds to insert a new row at the top.
Is Integromat correct that this is now unavoidable? Or is there a solution that I can implement or tell them to implement?
The workaround for now will be that we don't hide orders in that sheet but that's not a great long-term solution for us.
The problem can be caused by the first cell of the caption. It seems like integromat (aka make) can't handle it and thinks there is no caption. Then it just adds the new entry as the first line. Once the very first cell in the title contains data, it should work again.

Alternative to Excel INDIRECT that works on closed files, and links to workbook based on cell value?

I've seen many questions on this forum about linking Excel files based on cell values and INDIRECT always pops up as an answer, and it does do function and fill my sheet the way that I want, but I need to find a way to work with the source file being closed. My problem when it comes to linking, is that the file path to pull the data from will not be known until part of the file name is entered into a cell.
For example, in 'Print Summary' workbook, Sheet1 Cell A2 is where the file name is entered as a number 12345 (and gets auto-formatted to place 'WIP' in front) which represents WIP12345.xls. WIP12345.xls is a form that holds information that needs to populate certain columns across row 2. WIP12345.xls is an order form and completed days ahead. Once it has been approved, the summary workbook is updated with the WIP#.
I did CONCATENATE WIP12345 and .xls to create the file name WIP12345.xls on Sheet2, and I have a Macro that copies and pastes special as value to turn the result into text. But, I can't find a way to create a formula that will take this value and lookup the file to pull information from. I need to pull and fill information from different cells to 10 columns down 43 rows (each row representing a different WIP#####.xls file).
I'm guessing VBA is the only way to go, but I have no idea how to write it. Anyone have a direction they can point me in? I hope I'm coming across clearly.
The free add-in morefunc.xll contains a function called Indirect.Ext, which works with closed worbooks.

Permissions in Excel

I have a sheet in Excel that has permissions set up to "Allow Users to Edit Ranges".
These different ranges consist of columns that users with different permissions can edit.
Is there any way to exclude cells/rows from these ranges?
For instance, I want to say I want the range of everything in column A except when cells in in column G of that row have nothing in them.
Alternatively, is there any way to use Macros to print out these complicated ranges?
You can select the cells with vba or manually and set the locked property to false before locking the sheet. This will allow the user to edit those range/cells.
You can use conditional formatting to identify these locked cells.
Select your range (ctrl-A for all the cells).
Conditional formatting
formula is: =CELL("protect",A1)=0
"Allow Users to Edit Ranges" only allows us to specify the range(s), not to apply a rule that would allow, or disallow, editing.
You could use Data Validation to produce an error message. For example, creating a Custom validation rule of
=K2<>""
in a particular cell would mean that an error message will be produced if they attempt to put a value into this other cell if K2 is empty. You need to uncheck the box which says Ignore Blank.
This is not foolproof though, as a Copy/Paste would wipe-out the rule.
It can be done with VBA, but even then it could be circumvented with Copy/Paste. However, the (for example) BeforeSave event could be used to check the content of these cells and produce a message and prevent the save.
Disclaimer: I don't know whether VBA works with a file that uses the "Allow Users to Edit Ranges" feature.

Does having a workbook that contains links to others affect the VBA code within it?

I have a workbook that uses values in the cells to generate tables used in Prophet. If instead of having values in cells, I have links to other workbooks, will this affect the VBA code in anyway? Are there any concerns that I need that I need to be aware of?
There will not be an effect to your macro.
Excel stores the value, as well as the link. So even if the link is not refreshed or the 'linked to' workbook is missing, there is still a value to return.
This snippet of code will return the cell value regardless of the link status.
A1 = Range("A1").Value
The biggest danger is users not refreshing the link, in which case you could be using old values. It is also possible for your users to break the link which converts the link from a formula to a value.

Populate table in Word Template with VBA?

I'm filling in a Word template with data that's been collected from user input. In particular a (variable) number of documents is chosen, and information about each document fills a row of a table.
I've bookmarked several items in the template and successfully filled information in the header from my macro, but the table I'm not so sure with. I bookmarked the first cell and tried tabbing (with Chr(9)) through, and also tried passing an array. (In the template the table has only a first row. Usually tabbing past the last column creates an additional row.)
I can retieve cell contents with
Word.Application.ActiveDocument.Tables(1).Cell(3, 1).Range.Text
but can't write to the any cell except the first, where I placed a bookmark.
Can anyone offer a possible solution to populate the table?
To populate table, use this code
ActiveDocument.Tables(1).Cell(1, 1).Range.Text = "Blah Blah"
This will write to the first cell in the first table. Use a loop to fill the rest of the cells.
I would also recommend see this link.
Topic: Automating Word Tables for Data Insertion and Extraction
Link: http://msdn.microsoft.com/en-us/library/aa537149%28v=office.11%29.aspx#Y1254
Extract:
Summary: Learn how to automate the creation and formatting of tables in Word. Get information about optimizing performance, populating a table with data, formatting table structure, linking table data, and extracting data from a table. (25 printed pages)
I've actually ran into a similar problem using Access to automate filling out a Word table template. I found that if I opened the template in Word prior to running the VBA script, then the Word document is successfully filled out with the table information. My code looks similar to yours as far as adding to it by row. Because the number of fields to be transferred to the form is dynamic it didn't seem like bookmarks for each section would work. If you have any update, I'd be happy to hear of a different way to resolve this.