Hay guys..
I'm building a new table using Excel. I want to use VB (maybe) to create a code that once a box (at the excel sheet) is "0" nothing happens but as soon as the box turn to "1" a window popup. in the window I wish to write "You now have more than 50 points".
Is it possible? If I can't use VB, How can I do it?
I'll be happy for some help with the code as well, I don't know VB so well...
Thanks!!
Amihay
Check out the Worksheet_Change Event. You can then use something like Msgbox("You now have more than 50 points.") to display an alert if the criteria is met.
Related
I have a small userform as interface to various VBA functions. I use these commonly for document automation like inserting tables formatted in certain way etc.
This works great, but I would like to have a workflow where I place the cursor at desired place, click the function, and can continue writing. Currently the form always keeps the focus after being clicked. The form is not modal.
So in image below, I have focus on (1) but want focus on (2) after VBA sub in form has completed.
I did try ending the macro with ActiveDocument.ActiveWindow.SetFocus which does not make a difference.
I could of course close the form after every macro, but I use it commonly, so this would be less preferred.
Please, try one of the two ways. Both of them have to work:
Word.Application.Activate
AppActivate ActiveDocument.ActiveWindow.Caption
I am looking for a simple macro I could activate with a form control button that would clear all of the form control option buttons on my sheet.
I have lists of options for industrial part specifications, of which only one may be selected per section. However, once one is selected, the form control option button stays filled in. I previously circumvented this by using checkboxes, where if you click the box again it will remove the check mark. However once I learned that I was to create the form in such a way that only one option could be selected per section, (for ease of use in case a less computer minded person were to use it) it became clear that option buttons were the right way to go.
So I need a simple macro that I can activate with a button that will clear these option buttons all to blank, as if none were selected. I have looked and tried some strings of code, but none have worked so far. Perhaps I am missing something obvious or looking for the wrong thing, but I dont think I am.
I have checked the following pages and tried their code:
http://www.mrexcel.com/forum/excel-questions/689865-how-clear-all-checkboxes-option-buttons-list-boxes-form-3.html
Re-setting all option buttons at once
http://www.excel-easy.com/vba/examples/option-buttons.html
I feel like this should be simple. A VBA macro code that will reset the FORM CONTROL Option Buttons to blank (which I believe is the false state?). No need to worry about having specific ranges to clear; one button to reset the sheet will do perfectly.
Thanks in advance for any help.
Cycle through the Shapes collection:
Sub Reset()
For Each vCtrl In ActiveSheet.Shapes
vCtrl.DrawingObject.Value = False
Next
End Sub
Hi I have a VBA application with a combobox selection option.One of the combobox option is Other which when user select that option an invisibled label will pops up and prompt the user to fill the txtOther control.now my question is how I can get rid of the prompted label and make it to invisible after user fill the txtOther and move(focused)in other control?
here is a shot of my app:
Thanks for your time and help
It depends on how often or when you want the check to be done. I couldn't find a good reference to show you all of this, but you can view your VBE.
Within the code behind your userform you can use events for the text box.
If you want the check done every time you leave the text box:
Use the TextBox_Exit event.
If you want it to fire whenever the contents are changed, used TextBox_Change. There's lots of options, but based on your explanation I'd probably use Exit.
This answer shows some syntax examples for using the Textbox_Exit event.
I'm a novice to VBA and I'm trying to make a simple macro where one can highlight a set of cells, click a button, and strikethrough the selected sells. After, you can select the cell again, click the same button, and remove the strikethrough.
I have been looking for decent documentation but, have yet to find anything.
Here's some code.
Also, I would love to know where the best documentation is on VBA.
Sub strikeOut()
Selection.Font.Strikethrough = True
End Sub
I also need help with the command button.
Thank you.
It looks like you're on the right path. Based on your code, I'm assuming you already have a command button created. If so try this:
Sub strikeOut()
With Selection.Font
.Strikethrough = Not .Strikethrough
End With
End Sub
To create a command button:
Excel 2003 and earlier:
Open up the Visual Basic toolbar and activate the Control Toolbox button. Another box/toolbar should appear with different control options.
Select the Button option and place it in the desired location.
Excel 2007 and later:
Click on the Developer tab/ribbon.
Select Insert and select Button and place it in the desired location.
*The steps below apply to all versions from this point forward.
Right-click on your new button and select Properties to give your button a name/caption.
Right-click again and select View Code.
In the ButtonName_Click() sub, add the strikeOut() call using either:
Call strikeOut()
or simply
strikeOut
To answer the second part of your question, it's hard to say what is the 'best' but here are some links that may help:
Chip Pearson's site
MSDN
OZgrid
I've finished my macro! But is there an easier way in runnning it?
I know two ways
Open Visual Basic, select the correct macro and run!
View Macro's, select the correct macro and run!
Is there an easier way, or are these the only two ways?
Thanks
Place a command button on your sheet, view its code in the VB editor, and edit it so it looks something like this:
Private Sub CommandButton1_Click()
Call MyMacro
End Sub
You can then just click your button every time you want to run your macro.
you can even create little smiley icon in your Toolbar so that it stays there and you can run it by clicking it or have shortcut keys attached to it.
There are several options:
Toolbar or Menu (Excel 2003 & earlier)
http://peltiertech.com/WordPress/how-to-assign-a-macro-to-a-toolbar-or-menu/
ActiveX control
http://peltiertech.com/WordPress/how-to-assign-a-macro-to-an-activex-control/
Button (Forms menu control) or Shape
http://peltiertech.com/WordPress/how-to-assign-a-macro-to-a-button-or-shape/