+ Reply to Thread
Results 1 to 4 of 4

Finding the first non-blank cell in a row and then applying a calculation

  1. #1

    Finding the first non-blank cell in a row and then applying a calculation

    Hi All,

    I need some help. I am trying to use a macro to go row by row and find
    the first non-blank cell (which should be a number) and then using that
    as a start point apply a 1/12th calculation to that cell and the next
    11 cells, but after that I want the range to go back to zero's. I am
    familiar with VBA and Macro's but this is more advanced then I am used
    to. Thanks


  2. #2
    MrScience
    Guest

    Re: Finding the first non-blank cell in a row and then applying a calculation

    somthing like this will loop through a range, then stop and perform a
    calculation when a non-blank cell is encountered.

    Sub findFirstNonBlankCell()

    Dim myRange As Range
    Dim myVar As Range
    Set myRange = Range("A2:A10") 'set range

    'begin loop
    For Each myVar In myRange
    Set nextVar = myVar.Offset(1, 0)

    If myVar = "" Then 'test to see if cell is
    empty
    Set myVar = nextVar 'proceed to next cell if empty
    Else 'else perform a
    calc.
    myVar.Value = myVar * 2 'peform a calucation
    End If
    Next
    End Sub


  3. #3
    Gary Keramidas
    Guest

    Re: Finding the first non-blank cell in a row and then applying a calculation

    this will give you the row of the 1st blank cell in A

    Option Explicit
    Dim Blankrow As Long
    Sub test()
    Blankrow = Worksheets("Sheet1").Range("a1").End(xlDown).Row + 1
    End Sub

    range("A" & Blankrow) will give you the cell address


    --


    Gary


    <[email protected]> wrote in message
    news:[email protected]...
    > Hi All,
    >
    > I need some help. I am trying to use a macro to go row by row and find
    > the first non-blank cell (which should be a number) and then using that
    > as a start point apply a 1/12th calculation to that cell and the next
    > 11 cells, but after that I want the range to go back to zero's. I am
    > familiar with VBA and Macro's but this is more advanced then I am used
    > to. Thanks
    >




  4. #4

    Re: Finding the first non-blank cell in a row and then applying a calculation

    Mr Science.

    Thanks, this works but how do I get it to stop performing the
    calculation after a certian number of cells. What I am creating is a
    revenue recognition model and it needs to find the first cell that has
    numbers in it and divide that by the number of periods it is being
    amortized for, but after those periods it needs to stop and look for
    the next value and do the same thing. Its a bit more dynamic then I am
    used to. Thanks for your help


+ 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