+ Reply to Thread
Results 1 to 9 of 9

Apply VBA Code to 2 Columns, then skip one and repeat.

  1. #1
    Registered User
    Join Date
    11-03-2020
    Location
    UK
    MS-Off Ver
    2016
    Posts
    8

    Question Apply VBA Code to 2 Columns, then skip one and repeat.

    Hi All,

    I have a piece of code here and I need to adjust the range to take into account new amendments made to the spreadsheet.

    I am adding a new column before the code range and a column after every 2 columns in the code range. I will add a screenshot of the spreadsheet and where the new columns will be.

    What I need the code to do is to work in the same columns it does now as otherwise it shifts by one and disrupts the whole spreadsheet.

    Here's the code:

    Please Login or Register  to view this content.
    Columns will be added here (in red) added columns in red.PNG
    Last edited by Ernestas98; 11-29-2020 at 12:02 PM.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Apply VBA Code to 2 Columns, then skip one and repeat.

    It's not clear from the image exactly what the new set up is, can you upload a sample workbook?
    If posting code please use code tags, see here.

  3. #3
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: Apply VBA Code to 2 Columns, then skip one and repeat.

    Welcome to our Forum...

    Please take a moment to read our forum rules...here
    Your post does not comply with Rule # 2
    2. Programming code must be enclosed in code tags to improve readability.
    Please Login or Register  to view this content.
    So...Edit your post...Highlight the code and press the # button
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  4. #4
    Registered User
    Join Date
    11-03-2020
    Location
    UK
    MS-Off Ver
    2016
    Posts
    8

    Re: Apply VBA Code to 2 Columns, then skip one and repeat.

    Quote Originally Posted by Norie View Post
    It's not clear from the image exactly what the new set up is, can you upload a sample workbook?
    Attached here
    Attached Files Attached Files
    Last edited by Ernestas98; 11-29-2020 at 12:04 PM.

  5. #5
    Registered User
    Join Date
    11-03-2020
    Location
    UK
    MS-Off Ver
    2016
    Posts
    8

    Re: Apply VBA Code to 2 Columns, then skip one and repeat.

    Quote Originally Posted by sintek View Post
    Welcome to our Forum...

    Please take a moment to read our forum rules...
    Your post does not comply with Rule # 2
    2. Programming code must be enclosed in code tags to improve readability.
    Please Login or Register  to view this content.
    So...Edit your post...Highlight the code and press the # button
    Updated, thank you

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Apply VBA Code to 2 Columns, then skip one and repeat.

    So starting in column G for every 3 columns you want the first 2 columns to trigger the code but not the 3rd column?

  7. #7
    Registered User
    Join Date
    11-03-2020
    Location
    UK
    MS-Off Ver
    2016
    Posts
    8

    Re: Apply VBA Code to 2 Columns, then skip one and repeat.

    Quote Originally Posted by Norie View Post
    So starting in column G for every 3 columns you want the first 2 columns to trigger the code but not the 3rd column?
    Yes

    So that the tick is in the "Shared?" column, the date in the "Date" and "likes" column is left for manual input

    Thank you

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Apply VBA Code to 2 Columns, then skip one and repeat.

    Try this.
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    11-03-2020
    Location
    UK
    MS-Off Ver
    2016
    Posts
    8

    Re: Apply VBA Code to 2 Columns, then skip one and repeat.

    Quote Originally Posted by Norie View Post
    Try this.
    Please Login or Register  to view this content.
    That worked perfectly! Thank you for saving the day again )

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] VBA code to apply same filter to adjacent columns of pivot table.
    By Ishwarind in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-25-2017, 07:00 AM
  2. Repeat same code in Macro but different Columns
    By chris2890 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-19-2016, 03:21 AM
  3. [SOLVED] Help with code to apply condidtional format to columns in Pivot Table
    By rv02 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-26-2015, 08:20 PM
  4. Formula to read code in Column D, then apply color to columns a, b, c?
    By Lorann in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-28-2014, 07:10 PM
  5. Replies: 4
    Last Post: 03-08-2014, 08:01 AM
  6. Add a Row, then Skip to next row and Repeat
    By talkinggoat in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-31-2010, 07:50 PM
  7. Apply color code to only 3 columns of filtered range
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-08-2009, 11:10 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1