I have a Drop Down in excel sheet. It has the values
NEW
DELETION
SUSPENDED
I want to make use to these values to perform some action. Say like if the value of the Cell is NEW is should check that and then work further.
when I write below code in VBA it doesn't work.
If Sheet5.Range("B16").Value = "NEW" Then
.... Perform some action...
Won't the above line work? Can't I compare the Value to "NEW".
Please note: The drop down is in excel sheet. How do I retrieve this Excel sheet dropdown value in macros?
This is not a dropdown, it's a Validation List, which is created from the Data ribbon like:
So the underlying cell, in your case E1, behaves like a normal cell except it can only accept certain values. You can access its properties in VBA as expected, for instance:
Debug.Print Range("E1").Value
So, your code should work if you call the macro from the Developer|Macros menu, or if you run it from the VBE using F5 key.
Related
The multiselect doesn't work if the worksheet is protected, even if the actual cell containing the dropdown list is unlocked. It just behaves like a normal data validation list, i.e. the code is ignored.
Is there any way to allow it to work even if the sheet is protected.
It just behaves like a normal data validation list, i.e. the code is ignored. I am expecting to be able to select more than one from the list on a locked spreadsheet.
I have made a Data Entry form in which i have recorded a macro Using "Use Relative Reference" from developers tab.
I have also added vlookup formula so that if a certain value or word is selected many of the fields being pulled or appears automatically.
I have created a button named as "Save Data" and have recorded a macro in it
After adding all the values (few values manually, few values I pull via Vlookup) whenever i press the button "Save Data" it moves the all values from data entry form to another Main Worksheet.
However the problem is whenever i press the button it also removes the formula of Vlookup and I have to either paste Vlookup formula again or add the values manually. the formula of Vlookup is
=VLOOKUP(C12,Functions!F$2:J$20,3,0)
Can anyone suggest if even after pressing the button and after moving the data the formula should remain there and i do not have to put them manually again and again
I have an excel file that has different formulas. What I am looking for is to modify only one element of that formula since due to the process that I am working on, the formula could change, but the period (eg 202112) is a field that must always exist, so I think I could not generate the formulas with a macro, since these are modified by another user. Is it possible to add a variable to the formula and update/change the value by pressing a button?
The following table is only to explain what I need, it is too simple, but it is not to enter the long formulas.
I would like to assign a macro to the button so that when pressing it the value of the variable "Period" is updated, for example 202112
Without using macro you should change the excel recalculates settings;
-In Excel, click the Microsoft Office Button, click Excel Options, and then click the Formulas category and in the Calculation options section, under Workbook Calculation, click Manual and uncheck the checkbox.
Use this formula for your Ids+Period column;
=B2&C2&TEXT(TODAY(),"yyyymm")
To update your cell formula (or date). You should click the cell and after that command line and click enter. Done!
I have a large file with a Scenario Manager, where changing a single cell on the Summary worksheet changes the visible scenario throughout the rest of the workbook. Data Tables are working a treat providing the headline values for each option.
I'd like to have a drop down on each sheet that when changed will change the same single cell on the Summary worksheet, so I don't need to go back to the Summary sheet every time I want to switch visible scenarios.
This is a simple process if I'm using macros and would be the solution I'd normally jump straight to. But this needs to be done without macros and this is where I'm now struggling.
Does anyone know if this is possible (without macros) and point me in the right direction?
Josh
You can insert combo box (Developer Tab > Insert > Form Controls > Combo Box) on each sheet. Mention linked cell as a cell of the summary sheet (Absolute reference with sheet name). That cell will give you index of the item selected in the drop down list. Then you can insert index formula in the cell you want to change every time to get value of the drop down list. Once you insert it on one sheet you can copy it to other sheets. No macros required.
I'm working out a dashboard for my office. It all works, but I wanted to add in an option that instead of searching through 250+ items in a dropdown, you could also click on a cell and the dropdown would change to that value, and the assigned macro would run for that dropdown. So far I can't figure out how to have vba select a specific item from a dropdown. I can have the text change, but that doesn't select the index of the dropdown.
Any suggestions?
If you are using an ActiveX drop down list, (a combobox) this is how you would change the selected value in the drop down list:
ComboBox1.Value = "New Value"
If you are using data validation as a drop down list, then you just need to change the cell value as you would change any other cell:
'assuming the drop down list (data validation) is in Cell(1, 1)
cells(1,1) = "New Value"
Also you could check this article I've written on my blog about working with drop down lists in VBA Excel VBA Drop Down Lists
I wanted to do the same: Select an option from several drop down lists, then "reset" all of them to a starting point. Recording a macro and change the drop down list wont work.
However, I did the following:
Start recording macro
I typed all the values I wanted to be the "starting point once reset on the drop down list
stop macro.
It worked. Now I hit the macro and I get all the values "reset". Cheap trick, I know but worked for me.