Using Tableau's Excel Add-in with VBA

Using Tableau's Excel Add-in with VBA

7/3/2015


Tableau's Data Reshaper Excel Add-In is a great tool for getting your data in a Tableau-friendly format. However, if you try to record a macro that includes using the data reshaper, you will see that it doesn't record anything at all. However, there is a bit of VBA you can use to include using the data reshaper in your macros and VBA scripts.

I'm not going to take credit for this, as I didn't write it. I found it on some forum or another a while back, but I couldn't find it when I was looking for it again a couple days ago. So, I figured I'd create a post on this in hopes that someone who is trying to write some VBA that includes using the data reshaper will find this article.

Here is the code:

Range("selected cell").Select
Run "tsiUnpivot", ActiveSheet, ActiveCell, ActiveSheet.Range(ActiveCell, Cells(ActiveCell.CurrentRegion.Rows(ActiveCell.CurrentRegion.Rows.Count).Row,
ActiveCell.CurrentRegion.Columns(ActiveCell.CurrentRegion.Columns.Count).Column)), ActiveCell.CurrentRegion, "", 0, False

For the selected cell line, insert the starting cell for the reformatter. When you click to reformat, it will ask you for the first (usually) numerical value, so that's the cell you would type in here. If you've been using the data reshaper, you know what I'm talking about.

That's all! Just copy and paste the code above and put it into your VBA scripts.




Check out more posts in the Tableau category!