+ Reply to Thread
Results 1 to 3 of 3

How to use the value of a cell as a column number of another cell in a for next loop?

  1. #1
    Registered User
    Join Date
    07-29-2012
    Location
    Budapest, Hungary
    MS-Off Ver
    Excel 2010
    Posts
    13

    Question How to use the value of a cell as a column number of another cell in a for next loop?

    Hi everybody,

    Private Sub CommandButton1_Click()

    For Counter = 9 To 47
    Set CurCell = Worksheets("Vote Counter").Cells(Counter, T11)
    If CurCell.Value <> "--" Then CurCell.Value = "Yes"
    Next Counter
    End Sub


    I am trying to make this For loop work, by using the value of cell T11 in the column number of the cell but getting this error message:
    "Application-defined or object-defined error"

    Obviously having the plain name of the cell T11 doesn't work, I just couldn't found any answer to this by Google-ing for similar scenarios.

    Of course, this For loop works by having a real number there.

    Would someone help me?

  2. #2
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: How to use the value of a cell as a column number of another cell in a for next loop?

    Quick and simple

    Please Login or Register  to view this content.
    edit:-

    Note that this assumes T11 in the active worksheet, otherwise you need to prefix [T11] with Worksheets("name").
    Last edited by jason.b75; 07-29-2012 at 09:52 AM.

  3. #3
    Registered User
    Join Date
    07-29-2012
    Location
    Budapest, Hungary
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: How to use the value of a cell as a column number of another cell in a for next loop?

    Jason,

    Thanks for the quick reply!

    George

+ 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