Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2006

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
michaelrepper@hotmail.com - 24 Jan 2006 04:00 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.