Solved

IF ERROR VB CODE

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

809 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