Dropdownlist with own formula as source?

MichiZH

New Member
Joined
Apr 3, 2013
Messages
5
Hi guys, my first post :)

I want to create a dropdown list as validation, with only certain worksheet names in my workbook. So I created an own formula, which lists all the worksheet names I want:

Code:
Public Function GetAllWorksheetNames() As String

    Dim strResult As String
    Dim boolSettingsFound As Boolean
    Dim cintWS As Integer
    
    
    boolSettingsFound = False
    For cintWS = 1 To Sheets.Count
        If Sheets(cintWS).Name <> strcWorksheets_Settings Then
            strResult = strResult & Sheets(cintWS).Name & ";"
        Else
            boolSettingsFound = True
        End If
    Next cintWS
    
    GetAllWorksheetNames = Left(strResult, Len(strResult) - 1)
End Function

And if I put now under validation, list the source as =getallworksheetnames() I get an error. Is this even possible?

I tried another approach where I write all worksheet names directly in a hidden column as soon as the respective sheet opens. And this was the source for the dropdown. However (since it was dynamic?) as soon as the entries changed from the original state, the list source didn't work anymore...
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

MichiZH

New Member
Joined
Apr 3, 2013
Messages
5
Thank you sir :)

Ah thats just the worksheet name. The formula works great. The output in a cell is for example:
Sheet1;Sheet2;Sheet3

But this doesn't work directly as source for the list?

<tbody>
</tbody><colgroup><col></colgroup>
 
Upvote 0

MichiZH

New Member
Joined
Apr 3, 2013
Messages
5
Thank you sir :)

Ah thats just the worksheet name. The formula works great. The output in a cell is for example:
Sheet1;Sheet2;Sheet3


<tbody>
</tbody>

But this doesn't work directly as source for the list?
 
Upvote 0

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
ADVERTISEMENT
You haven't declared or assigned anything to the variable strcWorksheets_Settings.
 
Upvote 0

MichiZH

New Member
Joined
Apr 3, 2013
Messages
5
Yes I did. Thats a public variable in my module. The formula does work like this with the ouput posted above. However this doesn't work in the dropdown validation list...
 
Upvote 0

Forum statistics

Threads
1,195,989
Messages
6,012,716
Members
441,722
Latest member
tpaman1975

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
Top