none
put array values in to excel sheet on particular column in Excel ADDIN RRS feed

  • Question

  • Hi Group,

    Need your help on one issue.

    I have an array MyArray() which holds list of values, say 100 lines and only one column.

    I am in needs to put these values on the below statement but its throwing error.

    "Paste special of range class failed"

    ExcelAddtemp.getWorksheet(

    Currentsheet.mytab).Cells(2, Columnindex).PasteSpecial(MyArray)

    can anyone pls help Thanks

    Friday, June 17, 2016 2:22 PM

Answers

  • Hi Convert VSTO Excel ADDIN 2013 to 2013,

    From your line of code its look like you want to write the Array value in one cell.

    you have use PasteSpecial. did you copy the value from Array?

    if so can we see your code for that.

    if you are not copying and try pastespecial then it will not work because there is nothing to paste.

    if you only want to set the array value in a cell then you can use the code below no need to use pastespecial.

        Private Sub ThisAddIn_Startup() Handles Me.Startup
    
            Dim Array(2) As String
            Array(0) = "Hello"
            Array(1) = "World"
    
            Application.ActiveSheet.Range("C5:C5").Value = Array(0) + Array(1)
        End Sub

    if you want to assign value of array in column one line in one cell then use the code below.

     Private Sub ThisAddIn_Startup() Handles Me.Startup
    
            Dim Array(2) As String
            Array(0) = "Hello"
            Array(1) = "World"
    
            Application.ActiveSheet.Range("C5:C5").Value = Array(0)
            Application.ActiveSheet.Range("C6:C6").Value = Array(1)
        End Sub

    you can also use loop to set all the values of array in column.

    Regards

    Deepak


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Monday, June 20, 2016 12:29 AM
    Moderator

All replies

  • Hi Convert VSTO Excel ADDIN 2013 to 2013,

    From your line of code its look like you want to write the Array value in one cell.

    you have use PasteSpecial. did you copy the value from Array?

    if so can we see your code for that.

    if you are not copying and try pastespecial then it will not work because there is nothing to paste.

    if you only want to set the array value in a cell then you can use the code below no need to use pastespecial.

        Private Sub ThisAddIn_Startup() Handles Me.Startup
    
            Dim Array(2) As String
            Array(0) = "Hello"
            Array(1) = "World"
    
            Application.ActiveSheet.Range("C5:C5").Value = Array(0) + Array(1)
        End Sub

    if you want to assign value of array in column one line in one cell then use the code below.

     Private Sub ThisAddIn_Startup() Handles Me.Startup
    
            Dim Array(2) As String
            Array(0) = "Hello"
            Array(1) = "World"
    
            Application.ActiveSheet.Range("C5:C5").Value = Array(0)
            Application.ActiveSheet.Range("C6:C6").Value = Array(1)
        End Sub

    you can also use loop to set all the values of array in column.

    Regards

    Deepak


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Monday, June 20, 2016 12:29 AM
    Moderator
  • Hi Convert VSTO Excel ADDIN 2013 to 2013,

    since you created this thread you did not give any response to the suggestions given by the community members.

    is your issue solved? did you got solution by yourself?

    if so then would you like to share the solution with our community so that if some other member have same issue like you will also get solution by your post.

    if you think that suggestion given by the community member can able to solve your issue then I would recommend you to mark the suggestion as an Answer.

    if your issue did not solved till now then please let us know so that we can try to provide you further suggestions to solve your issue.

    Regards

    Deepak


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, June 24, 2016 9:46 AM
    Moderator