+ Reply to Thread
Results 1 to 4 of 4

Cannot get the values of cells in a loop

  1. #1
    Registered User
    Join Date
    04-13-2011
    Location
    Atlanta GA
    MS-Off Ver
    Excel 2003
    Posts
    3

    Cannot get the values of cells in a loop

    Hello,
    I don't know if anyone can help. I am trying to see the values of the cell when looping, but it is on showing the value of the first cell only. Can you guide me on what I am doing wrong? Thanks in advance.
    Code below
    'Convert Column F to corresponding name in colmn A
    xlSource.Activate()
    xlSrcSheet = xlSource.Worksheets("sheet1")
    xlSrcRange = xlSrcSheet.Range("A1")

    'xlSrcRange.Select()

    For i = 1 To xlSrcSheet.UsedRange.Rows.Count
    xlSrcRange.Offset(i, 0).Select()
    'code goes here
    xlSrcRange.Select()
    Debug.Print(xlSrcRange.Value.ToString)
    Debug.Print(xlSrcRange.Cells.Value.ToString)
    NexT
    Last edited by ManFano; 04-14-2011 at 03:14 PM.

  2. #2
    Valued Forum Contributor jwright650's Avatar
    Join Date
    12-10-2010
    Location
    Va, USA
    MS-Off Ver
    Excel 2003, Excel 2010
    Posts
    606

    Re: Cannot get the values of cells in a loop

    Welcome to the forum.

    Just a note: Read Rule #3 of the forum rules about adding the code tags.

    EDIT:

    3. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Select your code and click the [#] button at the top of the post window (if you are editing an existing post, press Go Advanced to see the [#] button). The result will appear like this in the post window:

    Please Login or Register  to view this content.
    ... and appear like this when posted:


    Code:
    your code here ...
    and here ...
    and hereYou can also type the code tags in manually if you prefer. For more information about these and other tags, click here.
    Last edited by jwright650; 04-14-2011 at 02:58 PM. Reason: added copy of Rule #3
    Life is like a roll of toilet paper. The closer it gets to the end, the faster it goes.
    John Wright

  3. #3
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Cannot get the values of cells in a loop

    hi, ManFano, please read carefully Forum rules and add code tags to the posted code

  4. #4
    Registered User
    Join Date
    04-13-2011
    Location
    Atlanta GA
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Cannot get the values of cells in a loop

    Hello,
    Sorry, I missed the part where I have to put the quote around my code.
    I don't know if anyone can help. I am trying to see the values of the cell when looping, but it is on showing the value of the first cell only. Can you guide me on what I am doing wrong? Thanks in advance.
    Code below
    'Convert Column F to corresponding name in colmn A
    xlSource.Activate()
    xlSrcSheet = xlSource.Worksheets("sheet1")
    xlSrcRange = xlSrcSheet.Range("A1")

    'xlSrcRange.Select()

    For i = 1 To xlSrcSheet.UsedRange.Rows.Count
    xlSrcRange.Offset(i, 0).Select()
    'code goes here
    xlSrcRange.Select()
    Debug.Print(xlSrcRange.Value.ToString)
    Debug.Print(xlSrcRange.Cells.Value.ToString)
    NexT

+ 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