I need help to show all matches between two tables in excel. I've searched everywhere and didn't find any answer yet.
Please check the table on the image.
Table Sample:
Thank you.
Try this:
Set myNewRow = ActiveWorkbook.Worksheets(1).ListObject(1).ListRows.Add
FOR i = LBound(Table1) TO UBound(Table1)
FOR a = LBound(Table2) To UBound(Table2)
IF Table1(i).Value = Table2(a).Value THEN myNewRow(i) = Table2(a).Value
ENDIF
NEXT a
NEXT i
Where myNewRow is the result table. You are going to have to use the nested for loop to accomplish this.
You might want to try this (confirm with CTRLSHIFTENTER)
IFERROR(INDEX($B$2:$B$7,SMALL(IF($B$2:$B$7=TRANSPOSE($A$2:$A$3),ROW($C$1:$C$6)),ROW(A1))),"")
Related
I am working with list objects in excel and there is one thing that puzzles me:
according to this and many other sites I visited the following line of code is a range:
mytable.headerRowRange("nameofColumn")
mytable being a listobject of a particular sheet.
what I wand to do is hide that column
but this would not work:
mytable.headerRowRange("nameofColumn").EntireColumn.Hidden=True
Why?
the error is: Invalid procedure call or argument.
thanks.
mytable.ListColumns("ID").Range.EntireColumn.Hidden = True
You could also have done
mytable.HeaderRowRange.Find("id").EntireColumn.Hidden = True
class_abbrevs_2 = [x.text for x in subject_page.find_all('td')[1].find_all('a')]
I am going through opening each link and then here is the page that is giving me the problem. It only has the one 'td', this has only a single td:
http://registrar.indiana.edu/browser/soc4168/CTIH/index.shtml
and here is what a normal page looks like that has 2 'td':
http://registrar.indiana.edu/browser/soc4168/CSCI/index.shtml
Can someone tell me how I can run this line only if it's true. I can't figure out the syntax. Just for a little background if needed I am webscraping with python and BS4. Lmk if there is any other info that would help. Thanks
If I understand correctly from the comment above, I think you just want this?
tds = subject_page.find_all('td')
if len(tds) > 1:
class_abbrevs_2 = [x.text for x in tds[1].find_all('a')]
You can simplify the code to a select using nth-of-type to look for a second td:
text = [a.text for a in soup.select("#crsebrowser td:nth-of-type(2) a")]
If there is no second td inside the table then it will find nothing so you with end up with a list of text from the anchors or nothing so you don't need any other logic to get the data.
I have some code referencing Slicers:
For Each item In wb.SlicerCaches("Segment").SlicerItems
If item.Selected = True Then
If Len(sSegment) > 0 Then sSegment = sSegment & "|"
sSegment = sSegment & item.Caption
End If
Next item
but I get Invalid procedure call or argument. I've seen many examples referencing them by name, but can't get it to work. If I use (1), (3) etc and then add a slicer, it messes up the order, so the code is mucked up.
How can I reference them by name, my end goal is to iterate through selected items.
You may need to reference the slicercache by adding Slicer_ in front of it.
For example, I added an Authors slicer to a table containing information about books and I could reference it by using this code:
Debug.Print ActiveWorkbook.SlicerCaches("Slicer_Author").Slicers("Author").Caption
The reason I knew to add Slicer_ is because I right clicked the slicer and then selected Slicer Settings... and saw this:
And that seems to reference the slicer fine. It was really dumb luck that I happened to see that and thought to try it.
Try:
For Each item In wb.SlicerCaches.Item("Segment").SlicerItems
I'm trying to change values of an excel workbook using Update but something is wrong i.e. y want to get the value from table B and put it in table a
my code is this, can you help me?
UPDATE [Data$]
SET A.[D ArtN] = B.[D ArtC]
FROM [Datos$] as A
INNER JOIN [Productos$] as B
ON A.[Art] = B.[ArtC]
UPDATE [Data$]
SET [Data$].[D ArtN] = [Productos$].[D ArtC]
WHERE [Data$].[Art] = [Productos$].[ArtC]
Is the correct format of an update statement. I'm not sure that this is the correct SQL syntax, as you did not specify if what you were using in Excel.
http://www.w3schools.com/sql/sql_update.asp
I want to select some values through VBA in Pivot Table which is linked to OLAP Cube.
As I know such modification can be realised by typing:
ActiveSheet.PivotTables("PivotTable1").PivotFields("[parameter].[parameter]").VisibleItemsList = Array("value1","value2","value3")
Since get list of parameters from cells in Excel sheet, I wrote simple function which - In mentioned example - returns:
""value1","value2","value3""
I can't use such string as parameter for Array function (as it recognize it as one string), so I've tried to convert it to Array of Variant, typing above code:
Dim tableVar() As Variant
myVar = Replace(myVar, Chr(34), "")
myVar = Split(myVar, ",")
lowerB =LBound(myVar)
upperB = UBound(myVar)
ReDim tablica(lowerB To upperB)
For i = lowerB To upperB
tableVar(i) = myVar(i)
Next i
Unfortunately it changes nothing - when I'm calling:
ActiveSheet.PivotTables("PivotTable1").PivotFields("[parameter].[parameter]").VisibleItemsList = tableVar
I'm still receiving an error message.
Could you help me, please?
you have a typo in your code, daty should say myVar.
(Either that or we're missing more details)
Stupid thing, but error message is simply correct - there's no such items in Cube:
Run-time error '1004': The item could not be found in the OLAP Cube
I gave incorrect parameter here:
ActiveSheet.PivotTables("PivotTable1").PivotFields("[parameter].[parameter]").VisibleItemsList = tableVar
My code was unnecessary complicated - sorry for wasting your time.
Now my problem will be - how to check if specific dimensions or whole Cube exist...
Thanks once more for help.