Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Need a accumulator driven from second cell

I am new to VBA, just got book yesterday.
Found some code for entering on a column works get all by itself, but does
not help with problem.
Also found code for a single cell accumulator, also work real well all by
itself.
Need to marry these two codes, so that I input on column C and get an
accumulative total on column F. Here are the codes:

Sub ChkColC()
If ActiveCell.Column = 3 Then
If Not IsEmpty(ActiveCell) And ActiveCell < "" Then
MsgBox "Has Data"
Else
MsgBox "No Data"
End If
End If
End Sub

-AND-

Dim Val
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Cells.Count < 1 Then Exit Sub
If Target.Address = "$F$4" And IsNumeric(Target) Then
Application.EnableEvents = False
Target = Target + Val
Application.EnableEvents = True
End If
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Target.Cells.Count < 1 Then Exit Sub
If Target.Address = "$F$4" And IsNumeric(Target) Then
Application.EnableEvents = False
Val = Target
Application.EnableEvents = True
End If
End Sub

Need help please; thank you,
Jay

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default Need a accumulator driven from second cell

Hi Jay

Assuming you want to accumulate on the F column try this:

Dim Val(65536) As Double

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Cells.Count < 1 Then Exit Sub
If Target.Column = 6 And IsNumeric(Target) Then
Application.EnableEvents = False
Target = Target + Val(Target.Row)
Application.EnableEvents = True
End If
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Target.Cells.Count < 1 Then Exit Sub
If Target.Column = 6 And IsNumeric(Target) Then
Application.EnableEvents = False
Val(Target.Row) = Target
Application.EnableEvents = True
End If
End Sub

HTH,


Wouter
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Need a accumulator driven from second cell

Hello Wouter HM,

That works for F column only; works beautifully by the way; but I'm trying to
get the input from C column with the accumulation in F Column (all in the
same row; so I enter 5 in C4 and in F4, 5 will be added to whatever is in F4
then return the total back to F4)

Thanks,
Jay

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default Need a accumulator driven from second cell

On 9 mrt, 21:37, "Jay108" <u58645@uwe wrote:
Hello Wouter HM,

That works for F column only; works beautifully by the way; but I'm trying to
get the input from C column with the accumulation in F Column (all in the
same row; so I enter 5 in C4 and in F4, 5 will be added to whatever is in F4
then return the total back to F4)

Thanks,
Jay


Hi Jay,

Now it was clear to me what you really wanted.
Try this:


Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count < 1 Then Exit Sub
Application.EnableEvents = False
If Target.Column = 3 Then
If IsNumeric(Target) Then
If IsNumeric(Target.Offset(0, 3)) Then
Target.Offset(0, 3).Value = Target.Offset(0, 3).Value +
Target.Value
End If
End If
End If
Application.EnableEvents = True
End Sub

Wouter
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Need a accumulator driven from second cell

Thank you, thank you, many thank you's.
Works exactly like I want; But you have solved a major problem for me.
I'm going to study this book a little harder,
hopefuly I will be able to do stuff like this as well.

Sincerely,
Jay



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
two cell accumulator Sam Wilson Excel Programming 0 November 4th 09 12:03 PM
Need help with two cell accumulator dlashley Excel Worksheet Functions 1 May 12th 06 11:02 AM
Two cell accumulator Bill Excel Worksheet Functions 4 August 21st 05 09:07 PM
Two cell accumulator Bill Excel Worksheet Functions 1 January 3rd 05 03:15 PM
Help with code for two cell accumulator ToddG Excel Programming 3 January 21st 04 01:32 PM


All times are GMT +1. The time now is 02:23 AM.

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"