Solved

IF ERROR VB CODE

Posted on 2012-03-16
1
299 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

622 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