+ Reply to Thread
Results 1 to 6 of 6

How to use a variable cell reference in a loop?

  1. #1
    Registered User
    Join Date
    02-12-2013
    Location
    O'Fallon, MO
    MS-Off Ver
    Excel 2010
    Posts
    8

    How to use a variable cell reference in a loop?

    Hi All,

    Having a basic issue with declaring a cell value in a loop while trying to step through cells to count the number of "/" in the string. I can step through the cells, but I am not able to set a variable cell attribute when using Len() or Substitute().

    I have tried:
    Please Login or Register  to view this content.
    And also have tried using
    Please Login or Register  to view this content.
    Neither works?? Any Ideas?

    BTW it works fine with a single cell reference "A1" I just need to loop this through some columns on a single row.

    Please Login or Register  to view this content.
    Last edited by mullock; 02-12-2013 at 11:25 AM.

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: How to use a variable cell reference in a loop?

    Please Login or Register  to view this content.
    If solved remember to mark Thread as solved

  3. #3
    Registered User
    Join Date
    02-12-2013
    Location
    O'Fallon, MO
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: How to use a variable cell reference in a loop?

    Sample.xlsm

    You solved that!

    Now I have a new problem

    I am looping through columns and deleting selected ones. When I delete one the loop skips the next column I assume because the Shift left of the columns making my column number appear to be done already.

    I tried to re-establish rw as "rw = rw - 1" but that screwed it all up.

    Please Login or Register  to view this content.
    Thanks again...
    Last edited by mullock; 02-12-2013 at 01:40 PM. Reason: Add Workbook

  4. #4
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: How to use a variable cell reference in a loop?

    if you want delete rows you have to start the loop from the bottom, as this example
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    02-12-2013
    Location
    O'Fallon, MO
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: How to use a variable cell reference in a loop?

    I am not deleting rows, I am deleting columns but that is not the problem, the problem is that when I delete the column, the loop in my example skips the next column because the Column numbers change.

  6. #6
    Registered User
    Join Date
    02-12-2013
    Location
    O'Fallon, MO
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: How to use a variable cell reference in a loop?

    I just decided that it might be easier to Hide the column, that way it is still on the sheet If I need it.

    Works!

    Thanks,

    mullock

+ 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