+ Reply to Thread
Results 1 to 8 of 8

How to apply the codes for 2 columns in For each... in...

  1. #1
    Registered User
    Join Date
    07-01-2015
    Location
    Singapore
    MS-Off Ver
    2013
    Posts
    66

    How to apply the codes for 2 columns in For each... in...

    I want to apply the code below for Column T without Copy the same codes.
    Apply for both Column S and Column T

    Any way to do this ?
    Thanks in advance .


    Please Login or Register  to view this content.
    Last edited by fluffyvampirekitten; 07-31-2015 at 01:28 AM.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,330

    Re: How to apply the codes for 2 columns in For each... in...

    Try changing
    For Each rng In Wkb1.ActiveSheet.UsedRange.Columns("S")Cells
    to
    For Each rng In Wkb1.ActiveSheet.UsedRange.Columns("S:T")Cells

    See what happens.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: How to apply the codes for 2 columns in For each... in...

    Hi there,

    Assuming the above code works, make this line of code the very first line in your above procedure...

    Please Login or Register  to view this content.
    ...and this line the very last piece of code in your above procedure:

    Please Login or Register  to view this content.
    Regards,

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  4. #4
    Registered User
    Join Date
    07-01-2015
    Location
    Singapore
    MS-Off Ver
    2013
    Posts
    66

    Re: How to apply the codes for 2 columns in For each... in...

    Quote Originally Posted by MarvinP View Post
    Try changing
    For Each rng In Wkb1.ActiveSheet.UsedRange.Columns("S")Cells
    to
    For Each rng In Wkb1.ActiveSheet.UsedRange.Columns("S:T")Cells

    See what happens.
    I tried using this method but it doesn't work.

  5. #5
    Registered User
    Join Date
    07-01-2015
    Location
    Singapore
    MS-Off Ver
    2013
    Posts
    66

    Re: How to apply the codes for 2 columns in For each... in...

    Quote Originally Posted by Trebor76 View Post
    Hi there,

    Assuming the above code works, make this line of code the very first line in your above procedure...

    Please Login or Register  to view this content.
    ...and this line the very last piece of code in your above procedure:

    Please Login or Register  to view this content.
    Regards,

    Robert
    How to do this ?

    Please Login or Register  to view this content.

  6. #6
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: How to apply the codes for 2 columns in For each... in...

    Try this:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    07-01-2015
    Location
    Singapore
    MS-Off Ver
    2013
    Posts
    66

    Re: How to apply the codes for 2 columns in For each... in...

    Quote Originally Posted by Trebor76 View Post
    Try this:

    Please Login or Register  to view this content.
    I got this run-time error '91':
    Object variable or With block variable not set.
    Then this was highlighted
    Please Login or Register  to view this content.

  8. #8
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: How to apply the codes for 2 columns in For each... in...

    Like I said at the beginning - my examples are based on your code working

    From that error message it would seem that the rng variable hasn't been set to anything.

    Please don't quote entire threads - only specific parts to support your request.

    Good luck with it.

    Robert

+ 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. Replies: 0
    Last Post: 02-05-2014, 12:34 AM
  2. [SOLVED] APPLY Header Codes
    By diakonos1984 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-03-2013, 03:48 PM
  3. [SOLVED] How to transpose columns to row using vba codes
    By ricardo2012 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 08-04-2012, 04:55 PM
  4. I have two columns (A) and (G) that have like product codes however
    By genesisoxygen@gmail.com in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 08-07-2006, 01:05 PM
  5. [SOLVED] I have two columns (A) and (G) that have like product codes however
    By genesisoxygen@gmail.com in forum Excel General
    Replies: 1
    Last Post: 08-04-2006, 03:25 PM
  6. I have two columns (A) and (G) that have like product codes however
    By genesisoxygen@gmail.com in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-04-2006, 03:25 PM
  7. [SOLVED] How do I apply a list of zip codes to a map in Excel?
    By Dan in forum Excel General
    Replies: 0
    Last Post: 04-28-2006, 01:00 PM

Tags for this Thread

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