Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Function working on whim
Hey everyone, first post here. Trying to figure out why a function I have written will work in one cell and not the other. In the case of what I have written, what row the active cell is should not matter but the active cell's column does. It should read a value from a specified row in that column and then perform a simple comparison. My issue is that while in the same column the function will work for one row but not the 2 above it, after those two it begins working again. What have I done to cause this to happen? Here is the code: (simplistic I know but I started learning VBA yesterday) Code: -------------------- Option Explicit Public Function eb(additive2 As Integer) As Double Dim count As Integer additive2 = Application.ThisWorkbook.Worksheets("Results").Cel ls(6, Application.ActiveCell.Column).Value eb = 0 count = 6 For count = 6 To 10 If Application.ThisWorkbook.Worksheets("Additive-Flush").Cells(count, 8).Value = additive2 Then eb = Application.ThisWorkbook.Worksheets("Additive-Flush").Cells(count, 14).Value + eb Else eb = eb + 0 End If Next count End Function -------------------- Thank you for your help. ~Jason -- jclark419 ------------------------------------------------------------------------ jclark419's Profile: http://www.excelforum.com/member.php...o&userid=25430 View this thread: http://www.excelforum.com/showthread...hreadid=388828 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Function working on whim
My first thought was that your code depends on the current activecell.
If you change that and recalculate, then the result could change. My second thought is that you're passing a variable called additive2. But the first line that does anything, essentially ignores the passed value. jclark419 wrote: Hey everyone, first post here. Trying to figure out why a function I have written will work in one cell and not the other. In the case of what I have written, what row the active cell is should not matter but the active cell's column does. It should read a value from a specified row in that column and then perform a simple comparison. My issue is that while in the same column the function will work for one row but not the 2 above it, after those two it begins working again. What have I done to cause this to happen? Here is the code: (simplistic I know but I started learning VBA yesterday) Code: -------------------- Option Explicit Public Function eb(additive2 As Integer) As Double Dim count As Integer additive2 = Application.ThisWorkbook.Worksheets("Results").Cel ls(6, Application.ActiveCell.Column).Value eb = 0 count = 6 For count = 6 To 10 If Application.ThisWorkbook.Worksheets("Additive-Flush").Cells(count, 8).Value = additive2 Then eb = Application.ThisWorkbook.Worksheets("Additive-Flush").Cells(count, 14).Value + eb Else eb = eb + 0 End If Next count End Function -------------------- Thank you for your help. ~Jason -- jclark419 ------------------------------------------------------------------------ jclark419's Profile: http://www.excelforum.com/member.php...o&userid=25430 View this thread: http://www.excelforum.com/showthread...hreadid=388828 -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
ISBLANK function not working when cell is blank dut to function re | Excel Discussion (Misc queries) | |||
RIGHT function not working | Excel Discussion (Misc queries) | |||
IF function not working | Excel Discussion (Misc queries) | |||
Function not working | Excel Worksheet Functions | |||
Function F3 key not working | Excel Worksheet Functions |