Create a choice field in Sharepoint list using VBA

pratiksuhasaria

New Member
Joined
Mar 26, 2019
Messages
24
Hi all,

I have developed a tool which creates a new list in sharepoint when I run a macro. But its takes datatypes of column only as
1) Single line of text
2) Number
3) Date

But I have a column in excel which has a drop down options but after running he marco, when I check my sharepoint list setting the column had datatype as single text of line.
But as I know there is option of choice as datatype in sharepoint which can be used as drop down list.

Please help me with .


VBA Code:
    Dim spList As ListObjects
    Dim newSPlist As ListObject
    Dim sheetName As String
    Dim spPath As String
    Dim spListName As String
       
    sheetName = Sheets("Dashboard").Range("J14").Value  ' name of sheet whose data neds to be created
    spListName = Sheets("Dashboard").Range("J16").Value ' name of the list in the sharepoint
    spPath = Sheets("Dashboard").Range("J18").Value ' path of sharepoint
    Set spList = Sheets(sheetName).ListObjects
    
    lastRow = Sheets(sheetName).Cells.Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    lastCol = Sheets(sheetName).Cells.Find(What:="*", SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
    lastColumn = Split(Cells(1, lastCol).Address, "$")(1)
    
    
    Set newSPlist = spList.Add(xlSrcRange, Sheets(sheetName).Range("A1:" & lastColumn & lastRow), True, xlYes)
    
    newSPlist.Name = spListName
    
    newSPlist.Publish Array(spPath, newSPlist.Name), True

Thanks
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,215,454
Messages
6,124,933
Members
449,195
Latest member
Stevenciu

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