Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88030

VBA - Custom Function Help (For Loop & Ranges)

$
0
0

I'm currently trying to right my own function for the first time and need some help with looping through a set of data. The code I have posted below allows me to set two variables "CFirstCell" and "CLastCell". This will return an address of "$I$4" and "$AL$4" for example. I now want to take these two variables and loop through the cells between those two ranges (within the sheet called "Client Configuration") and then store any values that aren't blank in an array called "AllCodes". Once I have all those values stored in the array "AllCodes", I want to loop through that array. Can someone please point me in the right direction? Thank you!

Public Function GETHOLDINGS(ClientId, Category, CategoryValue, DisplayValueAs) As String

    Dim ClientName As String
    Dim ReportingType As String    

    Dim CFirstCell As String
    Dim CLastCell As String

    Dim AllCodes As String

    ClientName = WorksheetFunction.Index(Sheets("Client Configuration").Range("Client_Config_Table[[#All],[Client Name]]"), _
    WorksheetFunction.Match(1, Sheets("Client Configuration").Range("Client_Config_Table[[#All],[ID]]")))

    ReportingType = WorksheetFunction.Index(Sheets("Client Configuration").Range("Client_Config_Table[[#All],[Portfolio Reporting Type]]"), _
    WorksheetFunction.Match(1, Sheets("Client Configuration").Range("Client_Config_Table[[#All],[ID]]")))

    CFirstCell = WorksheetFunction.Index(Sheets("Client Configuration").Range("Client_Config_Table[[#All],[C1]]"), _
    WorksheetFunction.Match(1, Sheets("Client Configuration").Range("Client_Config_Table[[#All],[ID]]"))).Address
    CLastCell = WorksheetFunction.Index(Sheets("Client Configuration").Range("Client_Config_Table[[#All],[C30]]"), _
    WorksheetFunction.Match(1, Sheets("Client Configuration").Range("Client_Config_Table[[#All],[ID]]"))).Address


    Select Case Category
        Case "Rating"

        End Select

End Function`

Viewing all articles
Browse latest Browse all 88030

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>