+ Reply to Thread
Results 1 to 6 of 6

Looping through columns

  1. #1
    Valued Forum Contributor
    Join Date
    11-27-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Office 365
    Posts
    1,172

    Looping through columns

    Hello,
    I thought that looping through columns would be the same as looping through rows, but this is not so
    From my limited knowledge in VBA, "Long" refers to rows and "Integer" refers to columns, please correct me if i am wrong.
    Here is what i have so far:

    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor
    Join Date
    02-06-2014
    Location
    N/A
    MS-Off Ver
    N/A
    Posts
    373

    Re: Looping through columns

    instead of range, use cells object reference, Cells(Row Index, Column Index)

    Please Login or Register  to view this content.
    Last edited by 1aaaaaaaaaaaaaaa; 03-21-2016 at 01:49 PM.

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Looping through columns

    Try:

    Please Login or Register  to view this content.

  4. #4
    Valued Forum Contributor
    Join Date
    11-27-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Office 365
    Posts
    1,172

    Re: Looping through columns

    Thanks Poizhan and John.
    Both answers are right on!
    Thanks!
    Question: Why can't i use the "Range" tool instead of having to use the "Cell" tool?

  5. #5
    Valued Forum Contributor
    Join Date
    02-06-2014
    Location
    N/A
    MS-Off Ver
    N/A
    Posts
    373

    Re: Looping through columns

    Range wants to reference a cell or grouping of cells by Column/Row in [A-Z][0-9] format, since you are using a numeric value to iterate through columns instead of an alphabetic value, the range reference will fail, e.g. "Range A1": (ColCel & NR), vba sees this as Range(11) which is invalid reference.

  6. #6
    Valued Forum Contributor
    Join Date
    11-27-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Office 365
    Posts
    1,172

    Re: Looping through columns

    Quote Originally Posted by Poizhan View Post
    Range wants to reference a cell or grouping of cells by Column/Row in [A-Z][0-9] format, since you are using a numeric value to iterate through columns instead of an alphabetic value, the range reference will fail, e.g. "Range A1": (ColCel & NR), vba sees this as Range(11) which is invalid reference.
    Ah! That makes sense!
    Thanks!

+ 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. looping through columns
    By ammartino44 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-03-2015, 08:59 PM
  2. Looping through columns
    By figuraluk in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-20-2013, 01:06 PM
  3. Looping through two columns
    By pablowilks in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-17-2013, 02:46 AM
  4. Do Until Looping (not looping through all other columns)
    By orle8050 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-11-2013, 10:37 AM
  5. Looping over columns
    By LATrojan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-27-2010, 08:12 PM
  6. Looping thru columns
    By Robert in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-15-2005, 05:05 AM
  7. [SOLVED] Help with looping thru columns
    By Chris-KPMG in forum Excel General
    Replies: 2
    Last Post: 05-19-2005, 04:06 PM

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