Vb script with excel 2010





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







-2















I have two sheets in Excel - all and ArticlesA.



I want to loop through the values in column B of the all sheet and see if the value is also in column B of the ArticlesA sheet.

If the value exists I want to copy the value from ArticlesA into a new column in all.



Sub stock()

Dim iall, i2, i3, k, kk, z

Dim wsall As Worksheet
Set wsall = Sheets("all")

Dim ws2 As Worksheet
Set ws2 = Sheets("ArticlesA")
iall = wsall.Range("B1").End(4).Row
i2 = ws2.Range("B1").End(4).Row

With wsall
For k = 2 To iall
z = .Range("B" & k)
For kk = 1 To i2
If z = ws2.Range("B" & kk) Then

Range("J" & kk).EntireRow.Interior.ColorIndex = 10

End If
Next
Next
End With

End Sub









share|improve this question

























  • Your question was a bit hard to follow (thus the close votes). I've reworded it and hopefully the meaning is still correct? As @EganWolf said in his answer - your code isn't doing what you ask. It's colouring the row in column J of the Activesheet rather than copying values to the all sheet. Feel free to roll back the update if I've got it wrong.

    – Darren Bartrup-Cook
    Jan 3 at 14:02


















-2















I have two sheets in Excel - all and ArticlesA.



I want to loop through the values in column B of the all sheet and see if the value is also in column B of the ArticlesA sheet.

If the value exists I want to copy the value from ArticlesA into a new column in all.



Sub stock()

Dim iall, i2, i3, k, kk, z

Dim wsall As Worksheet
Set wsall = Sheets("all")

Dim ws2 As Worksheet
Set ws2 = Sheets("ArticlesA")
iall = wsall.Range("B1").End(4).Row
i2 = ws2.Range("B1").End(4).Row

With wsall
For k = 2 To iall
z = .Range("B" & k)
For kk = 1 To i2
If z = ws2.Range("B" & kk) Then

Range("J" & kk).EntireRow.Interior.ColorIndex = 10

End If
Next
Next
End With

End Sub









share|improve this question

























  • Your question was a bit hard to follow (thus the close votes). I've reworded it and hopefully the meaning is still correct? As @EganWolf said in his answer - your code isn't doing what you ask. It's colouring the row in column J of the Activesheet rather than copying values to the all sheet. Feel free to roll back the update if I've got it wrong.

    – Darren Bartrup-Cook
    Jan 3 at 14:02














-2












-2








-2








I have two sheets in Excel - all and ArticlesA.



I want to loop through the values in column B of the all sheet and see if the value is also in column B of the ArticlesA sheet.

If the value exists I want to copy the value from ArticlesA into a new column in all.



Sub stock()

Dim iall, i2, i3, k, kk, z

Dim wsall As Worksheet
Set wsall = Sheets("all")

Dim ws2 As Worksheet
Set ws2 = Sheets("ArticlesA")
iall = wsall.Range("B1").End(4).Row
i2 = ws2.Range("B1").End(4).Row

With wsall
For k = 2 To iall
z = .Range("B" & k)
For kk = 1 To i2
If z = ws2.Range("B" & kk) Then

Range("J" & kk).EntireRow.Interior.ColorIndex = 10

End If
Next
Next
End With

End Sub









share|improve this question
















I have two sheets in Excel - all and ArticlesA.



I want to loop through the values in column B of the all sheet and see if the value is also in column B of the ArticlesA sheet.

If the value exists I want to copy the value from ArticlesA into a new column in all.



Sub stock()

Dim iall, i2, i3, k, kk, z

Dim wsall As Worksheet
Set wsall = Sheets("all")

Dim ws2 As Worksheet
Set ws2 = Sheets("ArticlesA")
iall = wsall.Range("B1").End(4).Row
i2 = ws2.Range("B1").End(4).Row

With wsall
For k = 2 To iall
z = .Range("B" & k)
For kk = 1 To i2
If z = ws2.Range("B" & kk) Then

Range("J" & kk).EntireRow.Interior.ColorIndex = 10

End If
Next
Next
End With

End Sub






excel vba






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 3 at 14:00









Darren Bartrup-Cook

14k11533




14k11533










asked Jan 3 at 11:56









mohamed medmohamed med

15




15













  • Your question was a bit hard to follow (thus the close votes). I've reworded it and hopefully the meaning is still correct? As @EganWolf said in his answer - your code isn't doing what you ask. It's colouring the row in column J of the Activesheet rather than copying values to the all sheet. Feel free to roll back the update if I've got it wrong.

    – Darren Bartrup-Cook
    Jan 3 at 14:02



















  • Your question was a bit hard to follow (thus the close votes). I've reworded it and hopefully the meaning is still correct? As @EganWolf said in his answer - your code isn't doing what you ask. It's colouring the row in column J of the Activesheet rather than copying values to the all sheet. Feel free to roll back the update if I've got it wrong.

    – Darren Bartrup-Cook
    Jan 3 at 14:02

















Your question was a bit hard to follow (thus the close votes). I've reworded it and hopefully the meaning is still correct? As @EganWolf said in his answer - your code isn't doing what you ask. It's colouring the row in column J of the Activesheet rather than copying values to the all sheet. Feel free to roll back the update if I've got it wrong.

– Darren Bartrup-Cook
Jan 3 at 14:02





Your question was a bit hard to follow (thus the close votes). I've reworded it and hopefully the meaning is still correct? As @EganWolf said in his answer - your code isn't doing what you ask. It's colouring the row in column J of the Activesheet rather than copying values to the all sheet. Feel free to roll back the update if I've got it wrong.

– Darren Bartrup-Cook
Jan 3 at 14:02












1 Answer
1






active

oldest

votes


















0














Your code is not doing what you said, but if you want to fix it, just specify the worksheet in line where you set a color of row:



ws2.Range("J" & kk).EntireRow.Interior.ColorIndex = 10





share|improve this answer
























    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%2f54021814%2fvb-script-with-excel-2010%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














    Your code is not doing what you said, but if you want to fix it, just specify the worksheet in line where you set a color of row:



    ws2.Range("J" & kk).EntireRow.Interior.ColorIndex = 10





    share|improve this answer




























      0














      Your code is not doing what you said, but if you want to fix it, just specify the worksheet in line where you set a color of row:



      ws2.Range("J" & kk).EntireRow.Interior.ColorIndex = 10





      share|improve this answer


























        0












        0








        0







        Your code is not doing what you said, but if you want to fix it, just specify the worksheet in line where you set a color of row:



        ws2.Range("J" & kk).EntireRow.Interior.ColorIndex = 10





        share|improve this answer













        Your code is not doing what you said, but if you want to fix it, just specify the worksheet in line where you set a color of row:



        ws2.Range("J" & kk).EntireRow.Interior.ColorIndex = 10






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 3 at 12:33









        Egan WolfEgan Wolf

        3,0101823




        3,0101823
































            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%2f54021814%2fvb-script-with-excel-2010%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

            android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

            SQL update select statement

            WPF add header to Image with URL pettitions [duplicate]