+ Reply to Thread
Results 1 to 4 of 4

Do within an If statement

  1. #1
    Tempy
    Guest

    Do within an If statement

    Hi, Tom Ogilvy gave me the following code, which works great. the
    problem i have is that as it loops down it must check if the ActiveCell
    is empty, if yes then do the Vlookup, if not then move one cell down to
    the next empty cell.
    My spreadsheet has +/- 5000 rows but must only apply the Vlookup to the
    empty cells in column X.

    Range("X1").Select
    Do
    ActiveCell.FormulaR1C1 = _
    "=VLOOKUP(RC[-23],LCS_Complete_E90.xls!C1:C12,2,0)"
    ActiveCell.NumberFormat = "dd-mmm-yy"
    activeCell.Offset(1,0).Select
    Loop until isempty(activecell.offset(0,-23))

    Could somebody please help me out of my misary ?

    Tempy

    *** Sent via Developersdex http://www.developersdex.com ***

  2. #2
    Bob Phillips
    Guest

    Re: Do within an If statement

    Range("X1").Select
    Do
    if activecell.value = "" Then
    ActiveCell.FormulaR1C1 = _
    "=VLOOKUP(RC[-23],LCS_Complete_E90.xls!C1:C12,2,0)"
    ActiveCell.NumberFormat = "dd-mmm-yy"
    End If
    activeCell.Offset(1,0).Select
    Loop until isempty(activecell.offset(0,-23))


    --
    HTH

    Bob Phillips

    "Tempy" <[email protected]> wrote in message
    news:%[email protected]...
    > Hi, Tom Ogilvy gave me the following code, which works great. the
    > problem i have is that as it loops down it must check if the ActiveCell
    > is empty, if yes then do the Vlookup, if not then move one cell down to
    > the next empty cell.
    > My spreadsheet has +/- 5000 rows but must only apply the Vlookup to the
    > empty cells in column X.
    >
    > Range("X1").Select
    > Do
    > ActiveCell.FormulaR1C1 = _
    > "=VLOOKUP(RC[-23],LCS_Complete_E90.xls!C1:C12,2,0)"
    > ActiveCell.NumberFormat = "dd-mmm-yy"
    > activeCell.Offset(1,0).Select
    > Loop until isempty(activecell.offset(0,-23))
    >
    > Could somebody please help me out of my misary ?
    >
    > Tempy
    >
    > *** Sent via Developersdex http://www.developersdex.com ***




  3. #3
    Tempy
    Guest

    Re: Do within an If statement

    Thanks Bob works a treat. Sorry for the time delay.

    Tempy

    *** Sent via Developersdex http://www.developersdex.com ***

  4. #4
    Bob Phillips
    Guest

    Re: Do within an If statement

    No problem, thanks for taking the time.

    Regards

    Bob

    "Tempy" <[email protected]> wrote in message
    news:[email protected]...
    > Thanks Bob works a treat. Sorry for the time delay.
    >
    > Tempy
    >
    > *** Sent via Developersdex http://www.developersdex.com ***




+ 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