How to hide text in certain cells from a script? - excel

Windows 10, Google Sheets, LVL: Rookie.
So I have a sheet, that is kinda like a scoreboard, the main purpose of it is to do scoreboard things, but that's irrelevant. Basically, for new people that use the sheet, I have green sentences near cells to show them what goes there, kinda like tutorials.
But, for people that have used the sheet for a while, they are going to get tired of all this extra space used up by green sentences that don't actually teach them anything cause they already know it.
SO I wanted to create a button from a UI box, that disables tutorials (Just hiding/deleting these green sentences), and whenever they wanted to see the tutorials "sentences" again, they could use another UI Button to enable them, which unhides/adds the text back in the cells.
I already have the UI Box setup...
The only thing I don't know how to do or what to code, is hiding/deleting these sentences, and being able to unhide/paste the sentences.
Now, if this can be done in an easy formula, please let me know, but otherwise, please help me write out a script for this. I will credit you if you wish.

You have a complicated spreadsheet that included about 25 text "hints" to user. You want experienced users to have the ability to "hide" the hints if they wish.
You could do this with a checkbox.
Untick (the default): the comments appear.
Tick the box: the comments are hidden
Create a checkbox (say, it is in Cell G1),
Edit all your hints along these lines.
=if($G$1=TRUE,"","Team name goes here --->")
Explanation
$G$1=TRUE`: this means that the check box has been ticked
if TRUE, then display nothing: ""
if not TRUE (the checkbox is NOT ticked), then display the hint. Such as "Team name goes here --->"

Related

CodeModle.Insertlines drops variables

After several days of searching Excel vba forums I have finally given in and must now ask for help.
The problem is that CodeModle.Insertlines causes excel to drop all variables. I have a couple arrays that I need to use / check boxes and list boxes etc. all get wiped when I run the code below
With Application.Workbooks(ActiveWorkbook.Name).VBProject.VBComponents("UserSavedQueries").CodeModule
.InsertLines 2, "tmp = " & """" & "THIS IS SOME SAMPLE TEXT " & """"
End With
I fully admit that the Insertlines was a bit of a work around as a way to an end, but that way now seems blocked. Please can someone advise how to insert lines into a module without resetting all variable?
For the bigger picture (and for someone to advise how I probably should have tackled this in the first place)
I have a sheet that pulls together a bunch of parameters from list boxes, checkboxes cells etc when a user selects the ‘Go’ button.
the selections are formatted to make a JSON message that is sent to an API and the response is displayed in a table on a second sheet.
To give some context, Imagine Listbox1 called “search criteria” with selections of “Manufacturer, Colours, Countries”. Listbox2 called “Filters” changes context depending on the selection on Listbox1. So we could have for Listbox2: “Ford, BMW, Nissan” , “Red, Blue, Green, Black, White”, “ ”. Not the actual data but it shows the varying length of each selection. There are actually around 12 available selections some of which have 100+ filter options.
The user may select “Ford, Red” which would return red Fords in all countries or “Ford,BMW,Green,Scotland” which would just Green Fords and BMWs in Scotland.
All of this works nicely.
NOW: I need to add the ability to have “Saved User Selections”. I need to avoid dumping these selections in a worksheet (even hidden) as it allows the user to “fiddle” with the shape and format of the selection which will break the JSON parsing. So I decided to save the user selections in a VB module. A UserForm provides the ability to Name the saved selection, date-stamp it and runs the code above. Parsing the UserSavedQueries module returns a listbox of all saved selections, which, when double-clicked are intended to populate listbox1 & 2 ready for the user to hit ‘Go’.
Considered options: I haven’t ruled out saving to an external file, or maybe even registry, but would prefer to keep self-contained within the one file.
This article came closest to helping, but I'm not sure how it would work for my use-case

How to emulate a mouse-click and similar degree of interactivity by an Office Add-In?

This will be my first Add-In. Please bear with me.
The goal of my add-in application is to replicate a very tedious, repetitive work by a user. She tells me that she initiates her task by clicking in some sort of combo box or drop-down menu and typing several digits, followed by a click on the "Ok" button.
Question No. 1: What is the official name of that contraption (the one in mustard color) and how is it coded into an Excel cell?
I gather than Add-Ins are coded using something called "Object Model"? I have seen about 4 lines of such code.
Is there a statement like this?
ClickOnCell("E32");
That contraption is a filter.
If she always types the same number into the filter search then you could store the filter as a custom view in the sheet.
Due to the lack of responses, both here and in 2 Microsoft forums, I have decided that the answer is:
There is no way
Then again, with only 13 people reading the question, the chances of one of them knowing the answer are very low.

Disable or delete right click menus VBA

Whenever I right click on an excel sheet two menus come up: one with cut, copy, paste, etc. and one with font size, bold, italic etc.
I can customize the first one to have whatever command I want. The problem I have is that I want to DISABLE or DELETE the second one (the one with font size, bold, italic etc.)
I tried going through the entire CommandBars collection but couldnt find the one that I need to delete.
Any ideas on how to achieve this?
Apparently its very easy.
Application.ShowMenuFloaties = True
Although this does the job, I still dont understand how to manipulate that menu.

To make entire row mandatory to fill if one cell of that row is filled

For ms Excel 2007.
I want the user to fill all cells in a row IF any one cell of that row is filled.
I am using ms-Excel 2007.
The only way I can think of to do this is by using a form. The form would have to be the only way that the user can enter data (you protect the worksheet and the form code "unprotects" it), then when the user fills out the form you check the fields for errors (not just omissions, but things like "that is not a valid date", etc).
To see what I mean, you can see a form at work for data entry in this tutorial. Maybe that's all you need, although there's not really solid data validation built in. But it will get you started.
Once you see how that works, you can try to design your own form that replicates the functionality of this one, but that includes error trapping. This involves opening the VBA editor (<Alt-F11>), inserting a user form, adding fields and buttons, and writing some code that is run when the "OK" button is clicked.
Not saying this is an easy thing to implement (I am guessing from the question that you may be new at this), but give it a shot. When you get stuck - post an update to your question or leave a comment.

form view in excel for a record

I have a sheet in excel that is basically like a database (yes it has to be in excel unfortunately) and I want to design a simple form to display the records (the different column values in the rows). Usually MS is good with making widgets to do this but I cant seem to figure out how to write it in VBA (easily)
Basically I have a list of Names and ID#'s then some other columns that need to be filled in (address, order # etc) but I'd like the user to do this via a form rather than typing in excel. I created a small form in VBA, but now I cant link the columns to the textboxes in the form.
Anyone know of any code I can plug and play to do this.
Specifically I am using a ComboBox (for the list of names) and then a for loop searching through it to find the selection and updating data. But its a real pain.
plus I cant figure out how to put in a 'Next' button, which is really annoying me. Does anyone know how to change the comboBox value to the next row, if it is linked via RowSource
Have you considered the Form feature? You can find under the commands you can add to your QuickAccess toolbar.
Check this helpful tutorial for additional details.

Resources