+ Reply to Thread
Results 1 to 4 of 4

Write a for loop from left to right

  1. #1
    Registered User
    Join Date
    04-23-2008
    Posts
    48

    Write a for loop from left to right

    Dear all,

    how to write a for loop to increase the cell from left to right as below:

    how to increase the range from Cells("1", "C") -> Cells("1", "D") ->Cells("1", "E") -> Cells("1", "F") from ABC...

    Please Login or Register  to view this content.
    Last edited by Leith Ross; 09-09-2011 at 04:42 AM. Reason: Added Code Tags

  2. #2
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Write a for loop from left to right

    Hi, your code neeeds to be enclosed in code tags or you'll get your knuckles rapped.

    As for your questions - you do realise that you can use numeric values for the column as well as the row, don't you? So Cells(1,3) is the same as Cells(1,"C") and Cells(1,4) is the same as Cells(1,"D") as so on. If you're looping it's much easier to use column numbers rather than try to reference the alphabetic address of the cell.

  3. #3
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Write a for loop from left to right

    What is the result you want ? numeric or text ?

    1 2 3 4 5 6

    or

    A B C D E F

    because you can do this using autofill; no VBA required.



  4. #4
    Registered User
    Join Date
    04-23-2008
    Posts
    48

    Re: Write a for loop from left to right

    Quote Originally Posted by Andrew-R View Post
    Hi, your code neeeds to be enclosed in code tags or you'll get your knuckles rapped.

    As for your questions - you do realise that you can use numeric values for the column as well as the row, don't you? So Cells(1,3) is the same as Cells(1,"C") and Cells(1,4) is the same as Cells(1,"D") as so on. If you're looping it's much easier to use column numbers rather than try to reference the alphabetic address of the cell.
    thanks, it solved.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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