Saturday, May 7, 2011

Data Validation List based on another data validation list

Have you ever thought how simple life could be if you could make your spreadsheets act more like a form without going through the trouble of creating one?  In today's example you can create a list of values in one field where another list is populated based on what the user selects!
Sub list2()
    With Cells(1, 2).Validation
            .Delete
        If Cells(1, 1) = "one" Then
            .Add Type:=xlValidateList, Formula1:="A, B, C"
            ElseIf Cells(1, 1) = "two" Then
                .Add Type:=xlValidateList, Formula1:="D, E, F"
            ElseIf Cells(1, 1) = "three" Then
                .Add Type:=xlValidateList, Formula1:="G, H, I"
        End If
    End With
End Sub
The above example will only refresh when the macro is run.  If you want this to run as soon as a value is chosen you may want to set this into the worksheet where an event will trigger it to run.

Thursday, March 3, 2011

Printing Multiple Sheets with VBA

Printing Multiple Sheets

Unhiding Multiple Worksheets

Most people who use Excel know that you can hide one or more sheets in Excel. Thanks to thesimplemachine.com we now have a short code for unhiding these sheets all at once rather than one at a time. Take a look!

Unhiding Multiple Sheets with VBA

Tuesday, March 1, 2011

Edit Multiple Selections in Excel Drop Down Lists

Microsoft has come up with an amazing array of features in Excel. One such feature is the drop down list which creates the ability for the user to provide feedback that drives other parts of the workbook. Gathering feedback from your audience not only allows your them to change scenarios as they see fit but it prevents you from recreating reports for each scenario.

As with any feature there are limitations. This is where the beauty of VBA comes into play! In yesterday's blog post from Contextures.com we are shown how you can handle problems with editing drop down lists:

Contextures Blog » Edit Multiple Selections in Excel Drop Down Lists