Write Data in two columns at once from userform selection












-1















i have been trying this the whole day couldn't figure out how.



So i have a list box in user form and it works pretty fine which means when a user selects and clicks at export to excel button it does the job it's suppose to do which means export the selected item in the 7th column.



what i wanted it to do now is to export that single selection to the 7th AND 8th column. Here is the current working



Set wf = Application.WorksheetFunction
Set addlist = Sheet1.Cells(Rows.Count, 7).End(xlUp).Offset(1, 0)
For x = 1 To WortSelector.ListCount - 1
If Me.WortSelector.Selected(x) Then
addlist = Me.WortSelector.List(x)
Set addlist = addlist.Offset(1, 0)
End If
Next x


so basically what i want is



 Set addlist = Sheet.Cells(Rows.Count, 8).End(xlUp).Offset(1,0)


Please help me with this. Thanks!










share|improve this question



























    -1















    i have been trying this the whole day couldn't figure out how.



    So i have a list box in user form and it works pretty fine which means when a user selects and clicks at export to excel button it does the job it's suppose to do which means export the selected item in the 7th column.



    what i wanted it to do now is to export that single selection to the 7th AND 8th column. Here is the current working



    Set wf = Application.WorksheetFunction
    Set addlist = Sheet1.Cells(Rows.Count, 7).End(xlUp).Offset(1, 0)
    For x = 1 To WortSelector.ListCount - 1
    If Me.WortSelector.Selected(x) Then
    addlist = Me.WortSelector.List(x)
    Set addlist = addlist.Offset(1, 0)
    End If
    Next x


    so basically what i want is



     Set addlist = Sheet.Cells(Rows.Count, 8).End(xlUp).Offset(1,0)


    Please help me with this. Thanks!










    share|improve this question

























      -1












      -1








      -1








      i have been trying this the whole day couldn't figure out how.



      So i have a list box in user form and it works pretty fine which means when a user selects and clicks at export to excel button it does the job it's suppose to do which means export the selected item in the 7th column.



      what i wanted it to do now is to export that single selection to the 7th AND 8th column. Here is the current working



      Set wf = Application.WorksheetFunction
      Set addlist = Sheet1.Cells(Rows.Count, 7).End(xlUp).Offset(1, 0)
      For x = 1 To WortSelector.ListCount - 1
      If Me.WortSelector.Selected(x) Then
      addlist = Me.WortSelector.List(x)
      Set addlist = addlist.Offset(1, 0)
      End If
      Next x


      so basically what i want is



       Set addlist = Sheet.Cells(Rows.Count, 8).End(xlUp).Offset(1,0)


      Please help me with this. Thanks!










      share|improve this question














      i have been trying this the whole day couldn't figure out how.



      So i have a list box in user form and it works pretty fine which means when a user selects and clicks at export to excel button it does the job it's suppose to do which means export the selected item in the 7th column.



      what i wanted it to do now is to export that single selection to the 7th AND 8th column. Here is the current working



      Set wf = Application.WorksheetFunction
      Set addlist = Sheet1.Cells(Rows.Count, 7).End(xlUp).Offset(1, 0)
      For x = 1 To WortSelector.ListCount - 1
      If Me.WortSelector.Selected(x) Then
      addlist = Me.WortSelector.List(x)
      Set addlist = addlist.Offset(1, 0)
      End If
      Next x


      so basically what i want is



       Set addlist = Sheet.Cells(Rows.Count, 8).End(xlUp).Offset(1,0)


      Please help me with this. Thanks!







      excel vba excel-vba






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Dec 29 '18 at 5:58









      ermias dillensawermias dillensaw

      34




      34
























          1 Answer
          1






          active

          oldest

          votes


















          0














          You cannot use the same variable name for two different columns.



          Set wf = Application.WorksheetFunction
          Set addlist = Sheet1.Cells(Rows.Count, 7).End(xlUp).Offset(1, 0)
          Set addlist2 = Sheet1.Cells(Rows.Count, 8).End(xlUp).Offset(1, 0)
          For x = 1 To WortSelector.ListCount - 1
          If Me.WortSelector.Selected(x) Then
          addlist = Me.WortSelector.List(x)
          Set addlist = addlist.Offset(1, 0)
          addlist2 = Me.WortSelector.List(x)
          Set addlist2 = addlist2.Offset(1, 1)
          End If
          Next x


          Hope this will help.



          OR just make column 7 and 8 equal (after the Next x):



          Worksheets(1).Range("H:H").Value = Worksheets(1).Range("G:G").Value





          share|improve this answer


























          • Thanks sdda, the second one works but when the user enter information in a new form it will replace the previous instead of going to the next empty cell and put the information on that cell. i really like the first code where you declare another variable (addlist2) i just dont know why it doesn't work, it does nothing at all.

            – ermias dillensaw
            Dec 29 '18 at 8:53











          • Hi sdda, okay so now i modified your code just a tiny bit and it works what i did is just change the .offset(1,0) to .offset(1,1). but i really really appreciate your help very much. Thank you!!

            – ermias dillensaw
            Dec 29 '18 at 9:02











          • hey, sorry, forgot the offset, you are right! :) Could you please mark my answer as solution?

            – sdda
            Dec 29 '18 at 11:18













          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53967102%2fwrite-data-in-two-columns-at-once-from-userform-selection%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          You cannot use the same variable name for two different columns.



          Set wf = Application.WorksheetFunction
          Set addlist = Sheet1.Cells(Rows.Count, 7).End(xlUp).Offset(1, 0)
          Set addlist2 = Sheet1.Cells(Rows.Count, 8).End(xlUp).Offset(1, 0)
          For x = 1 To WortSelector.ListCount - 1
          If Me.WortSelector.Selected(x) Then
          addlist = Me.WortSelector.List(x)
          Set addlist = addlist.Offset(1, 0)
          addlist2 = Me.WortSelector.List(x)
          Set addlist2 = addlist2.Offset(1, 1)
          End If
          Next x


          Hope this will help.



          OR just make column 7 and 8 equal (after the Next x):



          Worksheets(1).Range("H:H").Value = Worksheets(1).Range("G:G").Value





          share|improve this answer


























          • Thanks sdda, the second one works but when the user enter information in a new form it will replace the previous instead of going to the next empty cell and put the information on that cell. i really like the first code where you declare another variable (addlist2) i just dont know why it doesn't work, it does nothing at all.

            – ermias dillensaw
            Dec 29 '18 at 8:53











          • Hi sdda, okay so now i modified your code just a tiny bit and it works what i did is just change the .offset(1,0) to .offset(1,1). but i really really appreciate your help very much. Thank you!!

            – ermias dillensaw
            Dec 29 '18 at 9:02











          • hey, sorry, forgot the offset, you are right! :) Could you please mark my answer as solution?

            – sdda
            Dec 29 '18 at 11:18


















          0














          You cannot use the same variable name for two different columns.



          Set wf = Application.WorksheetFunction
          Set addlist = Sheet1.Cells(Rows.Count, 7).End(xlUp).Offset(1, 0)
          Set addlist2 = Sheet1.Cells(Rows.Count, 8).End(xlUp).Offset(1, 0)
          For x = 1 To WortSelector.ListCount - 1
          If Me.WortSelector.Selected(x) Then
          addlist = Me.WortSelector.List(x)
          Set addlist = addlist.Offset(1, 0)
          addlist2 = Me.WortSelector.List(x)
          Set addlist2 = addlist2.Offset(1, 1)
          End If
          Next x


          Hope this will help.



          OR just make column 7 and 8 equal (after the Next x):



          Worksheets(1).Range("H:H").Value = Worksheets(1).Range("G:G").Value





          share|improve this answer


























          • Thanks sdda, the second one works but when the user enter information in a new form it will replace the previous instead of going to the next empty cell and put the information on that cell. i really like the first code where you declare another variable (addlist2) i just dont know why it doesn't work, it does nothing at all.

            – ermias dillensaw
            Dec 29 '18 at 8:53











          • Hi sdda, okay so now i modified your code just a tiny bit and it works what i did is just change the .offset(1,0) to .offset(1,1). but i really really appreciate your help very much. Thank you!!

            – ermias dillensaw
            Dec 29 '18 at 9:02











          • hey, sorry, forgot the offset, you are right! :) Could you please mark my answer as solution?

            – sdda
            Dec 29 '18 at 11:18
















          0












          0








          0







          You cannot use the same variable name for two different columns.



          Set wf = Application.WorksheetFunction
          Set addlist = Sheet1.Cells(Rows.Count, 7).End(xlUp).Offset(1, 0)
          Set addlist2 = Sheet1.Cells(Rows.Count, 8).End(xlUp).Offset(1, 0)
          For x = 1 To WortSelector.ListCount - 1
          If Me.WortSelector.Selected(x) Then
          addlist = Me.WortSelector.List(x)
          Set addlist = addlist.Offset(1, 0)
          addlist2 = Me.WortSelector.List(x)
          Set addlist2 = addlist2.Offset(1, 1)
          End If
          Next x


          Hope this will help.



          OR just make column 7 and 8 equal (after the Next x):



          Worksheets(1).Range("H:H").Value = Worksheets(1).Range("G:G").Value





          share|improve this answer















          You cannot use the same variable name for two different columns.



          Set wf = Application.WorksheetFunction
          Set addlist = Sheet1.Cells(Rows.Count, 7).End(xlUp).Offset(1, 0)
          Set addlist2 = Sheet1.Cells(Rows.Count, 8).End(xlUp).Offset(1, 0)
          For x = 1 To WortSelector.ListCount - 1
          If Me.WortSelector.Selected(x) Then
          addlist = Me.WortSelector.List(x)
          Set addlist = addlist.Offset(1, 0)
          addlist2 = Me.WortSelector.List(x)
          Set addlist2 = addlist2.Offset(1, 1)
          End If
          Next x


          Hope this will help.



          OR just make column 7 and 8 equal (after the Next x):



          Worksheets(1).Range("H:H").Value = Worksheets(1).Range("G:G").Value






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Dec 29 '18 at 11:17

























          answered Dec 29 '18 at 7:13









          sddasdda

          263




          263













          • Thanks sdda, the second one works but when the user enter information in a new form it will replace the previous instead of going to the next empty cell and put the information on that cell. i really like the first code where you declare another variable (addlist2) i just dont know why it doesn't work, it does nothing at all.

            – ermias dillensaw
            Dec 29 '18 at 8:53











          • Hi sdda, okay so now i modified your code just a tiny bit and it works what i did is just change the .offset(1,0) to .offset(1,1). but i really really appreciate your help very much. Thank you!!

            – ermias dillensaw
            Dec 29 '18 at 9:02











          • hey, sorry, forgot the offset, you are right! :) Could you please mark my answer as solution?

            – sdda
            Dec 29 '18 at 11:18





















          • Thanks sdda, the second one works but when the user enter information in a new form it will replace the previous instead of going to the next empty cell and put the information on that cell. i really like the first code where you declare another variable (addlist2) i just dont know why it doesn't work, it does nothing at all.

            – ermias dillensaw
            Dec 29 '18 at 8:53











          • Hi sdda, okay so now i modified your code just a tiny bit and it works what i did is just change the .offset(1,0) to .offset(1,1). but i really really appreciate your help very much. Thank you!!

            – ermias dillensaw
            Dec 29 '18 at 9:02











          • hey, sorry, forgot the offset, you are right! :) Could you please mark my answer as solution?

            – sdda
            Dec 29 '18 at 11:18



















          Thanks sdda, the second one works but when the user enter information in a new form it will replace the previous instead of going to the next empty cell and put the information on that cell. i really like the first code where you declare another variable (addlist2) i just dont know why it doesn't work, it does nothing at all.

          – ermias dillensaw
          Dec 29 '18 at 8:53





          Thanks sdda, the second one works but when the user enter information in a new form it will replace the previous instead of going to the next empty cell and put the information on that cell. i really like the first code where you declare another variable (addlist2) i just dont know why it doesn't work, it does nothing at all.

          – ermias dillensaw
          Dec 29 '18 at 8:53













          Hi sdda, okay so now i modified your code just a tiny bit and it works what i did is just change the .offset(1,0) to .offset(1,1). but i really really appreciate your help very much. Thank you!!

          – ermias dillensaw
          Dec 29 '18 at 9:02





          Hi sdda, okay so now i modified your code just a tiny bit and it works what i did is just change the .offset(1,0) to .offset(1,1). but i really really appreciate your help very much. Thank you!!

          – ermias dillensaw
          Dec 29 '18 at 9:02













          hey, sorry, forgot the offset, you are right! :) Could you please mark my answer as solution?

          – sdda
          Dec 29 '18 at 11:18







          hey, sorry, forgot the offset, you are right! :) Could you please mark my answer as solution?

          – sdda
          Dec 29 '18 at 11:18




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53967102%2fwrite-data-in-two-columns-at-once-from-userform-selection%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Monofisismo

          Angular Downloading a file using contenturl with Basic Authentication

          Olmecas