+ Reply to Thread
Results 1 to 3 of 3

Formula in loop stops working

  1. #1
    Jim73
    Guest

    Formula in loop stops working

    Hi,

    I have a problem that I cant seem to find a solution to.

    -----------

    Do While rowcount < 24

    Tbook.Worksheets("Data1").Cells(i, j) =
    "=VLOOKUP(RC[-1],Library!R2C[-2]:R192C _ [1],3,FALSE)"
    rowount = rowcount + 1
    j = j + 1
    Loop

    -----------

    In the first iteration/cell the formula:
    =VLOOKUP(B21,Library!A$2:D$192,3,FALSE)
    comes up in the cell. (This is the way I want it).

    For my next iteration/cell following shows up:
    =VLOOKUP(RC[-1],Library!R2C[-2]:R192C[1],3,FALSE)
    i.e. it does not change the formula like it should. It fills the cell like
    it was text.

    Does anyone a solution to this?

    Thanx in advance
    Jim



  2. #2
    Bernie Deitrick
    Guest

    Re: Formula in loop stops working

    Jim,

    Perhaps your cell was formatted for text. Try

    Do While RowCount < 24
    With Tbook.Worksheets("Data1").Cells(i, j)
    .NumberFormat = "General"
    .FormulaR1C1 = "=VLOOKUP(RC[-1],Library!R2C[-2]:R192C[1],3,FALSE)"
    End with
    RowCount = RowCount + 1
    j = j + 1
    Loop

    HTH,
    Bernie
    MS Excel MVP

    "Jim73" <[email protected]> wrote in message
    news:[email protected]...
    > Hi,
    >
    > I have a problem that I cant seem to find a solution to.
    >
    > -----------
    >
    > Do While rowcount < 24
    >
    > Tbook.Worksheets("Data1").Cells(i, j) =
    > "=VLOOKUP(RC[-1],Library!R2C[-2]:R192C _ [1],3,FALSE)"
    > rowount = rowcount + 1
    > j = j + 1
    > Loop
    >
    > -----------
    >
    > In the first iteration/cell the formula:
    > =VLOOKUP(B21,Library!A$2:D$192,3,FALSE)
    > comes up in the cell. (This is the way I want it).
    >
    > For my next iteration/cell following shows up:
    > =VLOOKUP(RC[-1],Library!R2C[-2]:R192C[1],3,FALSE)
    > i.e. it does not change the formula like it should. It fills the cell like
    > it was text.
    >
    > Does anyone a solution to this?
    >
    > Thanx in advance
    > Jim
    >
    >




  3. #3
    Jim73
    Guest

    Re: Formula in loop stops working

    It worked. Now I dont need to work overtime (today) =)

    Thanx

    "Bernie Deitrick" wrote:

    > Jim,
    >
    > Perhaps your cell was formatted for text. Try
    >
    > Do While RowCount < 24
    > With Tbook.Worksheets("Data1").Cells(i, j)
    > .NumberFormat = "General"
    > .FormulaR1C1 = "=VLOOKUP(RC[-1],Library!R2C[-2]:R192C[1],3,FALSE)"
    > End with
    > RowCount = RowCount + 1
    > j = j + 1
    > Loop
    >
    > HTH,
    > Bernie
    > MS Excel MVP
    >
    > "Jim73" <[email protected]> wrote in message
    > news:[email protected]...
    > > Hi,
    > >
    > > I have a problem that I cant seem to find a solution to.
    > >
    > > -----------
    > >
    > > Do While rowcount < 24
    > >
    > > Tbook.Worksheets("Data1").Cells(i, j) =
    > > "=VLOOKUP(RC[-1],Library!R2C[-2]:R192C _ [1],3,FALSE)"
    > > rowount = rowcount + 1
    > > j = j + 1
    > > Loop
    > >
    > > -----------
    > >
    > > In the first iteration/cell the formula:
    > > =VLOOKUP(B21,Library!A$2:D$192,3,FALSE)
    > > comes up in the cell. (This is the way I want it).
    > >
    > > For my next iteration/cell following shows up:
    > > =VLOOKUP(RC[-1],Library!R2C[-2]:R192C[1],3,FALSE)
    > > i.e. it does not change the formula like it should. It fills the cell like
    > > it was text.
    > >
    > > Does anyone a solution to this?
    > >
    > > Thanx in advance
    > > Jim
    > >
    > >

    >
    >
    >


+ 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