Solved

IF ERROR VB CODE

Posted on 2012-03-16
1
291 Views
Last Modified: 2012-06-27
Hi All,
    This is a pretty simple VB question, but am a true beginner.  I made drop down menu which, when selected, will update two pivot tables. My report page points to information directly on the pivot, so when the date is changed, so does the report.  The problem I'm having is with dates that have no information on the pivot tables. Right now,  I have to index the dates in a lookup (i.e. for January I have to make a list of all the dates in January in consecutive rows.  This lookup is what populates the dates in the drop down menu.  Unfortunately, when there is no data for that date, it asks the user to set that date's information as the next one.  I definitely do not want that.  I want to code it so that if the date had no data, it would tell the user this and ask them to select another date.  The only VB code I am using is basically to change the filter on the date of two pivot tables to whatever the drop-down menu says.  The code says:

Sub updatePivot()
    [FilDate] = [selDate]
    [FilDate2] = [selDate]
End Sub

So i named the date filter for each pivot fildate and fildate 2 while the seldate is the output from the combo box.  So when I change the date on the drop-down menu to 1/22/2012, the seldate would also be 1/22/2012, which would change the fildates to the same date.  I'm just trying to make my work easier, so I can just copy a month's dates for my date lookup.  Currently, I have to run a separate pivot table, write down manually what dates don't have information, and then manually omit them from my index lookup.  Please help.
0
Comment
Question by:akatz66
1 Comment
 
LVL 13

Accepted Solution

by:
StellanRosengren earned 500 total points
ID: 37733264
You can populate the combo box with the dates that have information and then require a match. For example (when user clicks ok)
If Me.MyCombo.MatchFound=False Then
 'do not leave the userform, maybe give the user a message

/Stellan
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now