Converting dynamic ranges to a table using VBA

Fudging

New Member
Joined
Aug 26, 2022
Messages
10
Office Version
  1. 365
Platform
  1. Windows
Hi,

For context, I currently have functions that analyzes a table and I'm trying to make a new table from that data. I have multiple selection dropdown menus and I want to know all selections selected per row by making the possible selections as headers and indicating 1 or null if selected or not (please refer to the image). The end goal is to get this as a table and export it to Power BI for visuals.

The issue is that the formulas spill the data and for some reason, spilled data is not compatible with tables (using spill as the original table will constantly be growing). The plan is to have a VBA script that can read a worksheet and convert the range of spilled data into a table (if that is possible), assuming that my spilled data is in a separate worksheet. The reason for this odd approach is because the initial table will be constantly growing with more inputs, meaning the range of spilled data will also grow.

To summarize, I need help to write a VBA script that can read spilled data ranges that is bound to grow and convert it to a table.

Thanks in advance for the help :)

1684331929394.png
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
I hope that does what you need.

My workbook is HERE

VBA Code:
Function FindItem(psItemsString As String, psItemToFind As String) As Variant

'   Array to hold individual item.
    Dim asStrings() As String

'   Individual item.
    Dim iStringNum As Long
    
    FindItem = ""
    
    asStrings = Split(psItemsString, ", ")
    
'   Iterate through psItemsString to look for the value in psItemToFind
    For iStringNum = 0 To UBound(asStrings)
        
        If asStrings(iStringNum) = Trim(psItemToFind) _
         Then
            FindItem = 1
            Exit For
        End If
        
    Next iStringNum

End Function
 
Upvote 0

Forum statistics

Threads
1,215,218
Messages
6,123,676
Members
449,116
Latest member
HypnoFant

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top