Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
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
ISBLANK function not working when cell is blank dut to function re mcmilja Excel Discussion (Misc queries) 9 May 7th 23 03:43 AM
RIGHT function not working Jase Excel Discussion (Misc queries) 1 May 13th 08 09:08 PM
IF function not working Loren Excel Discussion (Misc queries) 5 May 5th 08 05:36 PM
Function not working donnaK Excel Worksheet Functions 8 December 8th 05 08:03 PM
Function F3 key not working wyattran Excel Worksheet Functions 0 August 8th 05 04:38 PM


All times are GMT +1. The time now is 11:47 PM.

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

About Us

"It's about Microsoft Excel"