Solved

IF ERROR VB CODE

Posted on 2012-03-16
1
292 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

947 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

20 Experts available now in Live!

Get 1:1 Help Now