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
MrScience - 24 Jan 2006 04:32 GMT
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
michaelrepper@hotmail.com - 24 Jan 2006 15:10 GMT
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
Gary Keramidas - 24 Jan 2006 04:37 GMT
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

Signature
Gary
> Hi All,
>
[quoted text clipped - 4 lines]
> familiar with VBA and Macro's but this is more advanced then I am used
> to. Thanks