Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default 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


wrote in message
oups.com...
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Finding Next Blank Cell in Blank Row Nick Wakeham Excel Worksheet Functions 3 June 11th 08 02:15 PM
Finding next non-blank cell Stu[_2_] Excel Discussion (Misc queries) 4 October 23rd 07 01:29 PM
Finding next blank cell JaiD Excel Programming 2 June 13th 04 10:23 AM
Finding the Blank Cell Cory Thomas[_2_] Excel Programming 0 June 2nd 04 05:54 PM
Finding first non-blank cell Allison[_2_] Excel Programming 7 October 18th 03 01:47 AM


All times are GMT +1. The time now is 01:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"