I'm starting with a Pivot Table that has all my data. One of the data fields is a URL string that I ultimately want to send my users to.
To make searching through the pivot table as easy as possible, I've got a couple slicer windows to let the users click their search criteria. What I'd like to do, is based upon their search criteria (once narrowed down to one result), is have a Macro Button that automatically launches their browser (lets say internet explorer) with the link found in the pivot table.
I can figure out the launching of the browser (or just a copy text), but is there a way that I can program the Macro Button's action based upon the selections of the Slicers that are associated with my pivot table?
Any help would be much appreciated!
If I understood you correctly, you want to launch your code when only one link appears in PivotTable (after you apply slicers to it).
You can achieve this with Worksheet_PivotTableChangeSync event and helper cell.
lets assume you have your pivot table in column G, starting from cell G2. Enter this this formula =COUNTA(G3:G20) in cell G1(adjust range to your needs).
then in your worksheet module (not regular module) enter this code.
Private Sub Worksheet_PivotTableChangeSync(ByVal Target As PivotTable)
Dim a As Long
a = Range("G1").Value
If a = 1 Then
'your code for link in cell G3
Else
End If
End Sub
Now when you slice your PivotTable to only one selection, COUNTA formula will evaluate to 1 and trigger Worksheet_PivotTableChangeSync event.
Related
I have created a ComboBox to do a Google-style search of Cities. I have my ComboBox on sheet 1, that is linked to a dynamic range of cities on sheet 2. The ComboBox output cell is what changes the dynamic range.
Here’s the problem I’m having. I start typing “sea” and I get two results in my drop down list-seaport and Seattle. So far so good. Then I use the down arrow to Select Seattle and the program crashes and restarts. I believe it is because when I hit down one time, seaport is selected and this narrows down my range to just the one option and Seattle disappears.
Is there any way around this? Either disabling the use of the keyboard down arrows for selections or preventing the output to the linked cell until a selection is finalized?
This the code for my combobox on Sheet1
Private Sub TempCombo_Change()
TempCombo.ListFillRange = "Cities"
Me.TempCombo.DropDown
End Sub
The named range "Cities" is defined by formula on sheet 2
='City Data'!$L$2:INDEX('City Data'!$L$2:$L$570,MAX('City Data'!$K$2:$K565,1))
I created a combobox of which the list of options updates whenever you type in the box. Just a bit like entering a search in google works with suggestions.
I followed this tutorial to do so: https://trumpexcel.com/excel-drop-down-list-with-search-suggestions/
There are 4 columns of data in the sheet that make this work, combined with a named range, and a short piece of VBA to update the combobox. The combobox is in linked to cell B3. And data is in E:H starting at row 3.
First column includes the options for the combobox. There are 5619 possible options to choose from.
Second column has the following formula to determine if the entry of the combobox is in the text of the same row in the first column: =--ISNUMBER(IFERROR(SEARCH($B$3,E3,1),""))
Third column has the following formula to establish the amount of matches found: =IF(F3=1,COUNTIF($F$3:F3,1),"")
Fourth column has the following formula to return the list of possible options based on the value typed in the combobox: =IFERROR(INDEX($E$3:$E$22,MATCH(ROWS($G$3:G3),$G$3:$G$22,0)),"")
The code to update the combobox is as follows:
Private Sub ComboBox1_Change()
ComboBox1.ListFillRange = "DropDownList"
Me.ComboBox1.DropDown
End Sub
With DropDownList Being a named range that selects all the names in the fourth column.
Now that I have this working on my desktop I want this to also work on mobile devices (tablets or smartphones). On my personal device, using the Microsoft Excel app, it is not supported (This version of excel doesn't support ActiveX-control elements). Is there a way to achieve the same result that would work on mobile devices?
I need a formula in MS Excel to get the last updated timestamp everytime any cell in a particular row is updated.I am using =if($2:$2="","",NOW()) but when one cell is updated, every cell even of other row having similar formula is updated with the latest time-stamp. What can be the problem?
I need only formula not a macro/excel program.
You will need to create a VBA macro in the worksheet change event. You can easily input a timestamp as a string into your row depending on the row of the changed cell. There is no formula that can do what you're asking.
To get to the worksheet change event, go to File, and then Options. Then go to Customize Ribbon. Check the box next to Developer in the column on the right. Under the newly added Developer tab in the Ribbon, select Visual Basic on the far left. Find you worksheet in the Project window on the left hand side of the Editor that opens up. You may need to expand your Workbook and a folder called Excel Objects. Double click on the sheet to get to its code. A window will open with two drop downs at the top. On the left, go to Worksheet. On the Right, select Change. In between Private Sub Worksheet_Change(ByVal Target As Range) and End Sub, you can add the code that will run whenever the worksheet is changed.
This is the code you would use, replacing "5" in Cells() with the column you want to put a timestamp in.
Dim i As Integer
i = Target.Row
Dim t As String
t = VBA.Now
Cells(i, 5) = t
If the cell to contain the timestamp is B3 and the cell to watch is C3 the formula is:
=IF(C3<>"",IF(B3="",NOW(),B3),"")
I am using =Hyperlink in a series of cells in a worksheet to call a public function that changes the value of a particular cell. It works very well. But I want the function to hide a row when I mouse over a particular cell. Can anyone help?
The code is:
Public Function highlightcell(seriesName As Range)
Range("valSelOption") = seriesName.Value
'enter code here to hide Row 1
End Function
You could try
Rows("1:1").RowHeight = 0
As an easy way to hide row 1
Simple Answer
There is no On Mouseover event in Excel.
This thread shows how you can achieve something similar using selection change, but it wont work for what you want.
http://www.ozgrid.com/forum/showthread.php?t=147219
Hiding a Row
Use this code:
ActiveSheet.Rows(2).Hidden=True
This will hide row 2.
Explaining Events in Excel
If you want the worksheet to react to the user (clicking a cell, changing a cell, calculating the sheet, opening the workbook, etc) you want to use Excel Events. This is a good explanation of Excel Events:
http://msdn.microsoft.com/en-us/library/office/hh211482(v=office.14).aspx
In excel workbook project, how could we detect if the filters on some worksheet are updated?
Make sure that you have a formula (e.g. COUNT) that includes an entire column of the data. In the case of a Table, turn on the Total row.
When the filter is changed, the Excel calculation event will fire because of the formula and you can pick this up by inserting the following code into the sheet.
Private Sub Worksheet_Calculate()
MsgBox "Calculation"
End Sub
Your sheet will need to be designed to only have data, otherwise code will be needed to determine if the calculation event on the sheet did not originate due to a change in filter.
You will need to add code to pick up the filter values. Focus on the Filter class members like Citeria1, Criteria2, Operator, On, etc.
My case was an Excel database. I created a label indicating "number of filtered items" or "number of meeting instances", so that when you filter using dropdown filters this label will update. I didn't find any "filter change" event. I tried the method described above like the following:
Select a cell in your sheet that you are not willing to use
Set the formula of the cell to "=count(B:B)" or "=counta(C:C)" or any formula that depends on the entire column. Make sure that the cell is not in the same column
Set the format type of this auxiliary cell to "custom" and set the format to ";;;" so the cell contents will be invisible
In VBA, use the "worksheet calculate" event to execute your code
Private Sub Worksheet_Calculate()
' The commands and actions you want to execute when filter changes
End Sub
Now, you are done