Why my code is not working??

jovie

Board Regular
Joined
Nov 13, 2015
Messages
68
Private Sub Value_Change(ByVal Target As Excel.Range)
If Not (Intersect(Target, Range("A1:A100")) Is Nothing) Then
Range("B1:B100").Value = Range("A1:A100").Value + Range("B1:B100").Value
End If
End Sub

I write this to trying to achieve that A1 +B1 =B1(New) ,A2+B2=B2(New), and so on
However, it is not working at all....
Anyone can help me
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Anyone can help me? Coz after I write this no matter how I write, it jus react as nothing
 
Upvote 0
I'm guessing it won't do anything because of the Sub Name.
Is this supposed to be a worksheet change event ??
AND
to achieve this
Code:
Range("B1:B100").Value = Range("A1:A100").Value + Range("B1:B100").Value
you will need a for / next loop to step through each line !!
 
Upvote 0
yup, I write as a change event. but I am writing like I type number in A1, then the A1+B1=B1(new), and when I type sth in A2, A2+B2=B2(New), is this also need a for next loop??
 
Upvote 0
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
 If Target.Column = 1 Then
 Target.Offset(, 1).Value = Target.Offset(, 1).Value + Target.Value
 End If
End Sub
 
Upvote 0
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
 If Target.Column = 1 Then
 Target.Offset(, 1).Value = Target.Offset(, 1).Value + Target.Value
 End If
End Sub
But I already have one change sheet code in the same sheet, what can I do to solve this problem, I mean same sub name
 
Upvote 0
But I already have one change sheet code in the same sheet, what can I do to solve this problem, I mean same sub name

A) you should state things like that in your first post
B) you merge the 2 codes together
C) if you don't know how to do it then you post both codes in the thread, then if no-one responds before I get home from work I will take a look at it.
 
Upvote 0
A) you should state things like that in your first post
B) you merge the 2 codes together
C) if you don't know how to do it then you post both codes in the thread, then if no-one responds before I get home from work I will take a look at it.
Private Sub Worksheet_Change(ByVal Target As Range)

Dim rng As Range

Set rng = Target.Parent.Range("Moving_Stock_out")

If Target.Count > 1 Then Exit Sub

If Intersect(Target, rng) Is Nothing Then Exit Sub
Target.Offset(, 15).Value = Date

End Sub


Private Sub Value_Change(ByVal Target As Range)
If Intersect(Target, Range("Moving_Stock_in")) Is Nothing Then
Range("Acutal_Balance").Value = Range("Actual_Balance").Value + Target.Value
End If
End Sub

Actually I really dun know how to merge the codes, I try to put them tgt as one code, however, It is not working, so can help me? thanks
 
Upvote 0

Forum statistics

Threads
1,215,042
Messages
6,122,810
Members
449,095
Latest member
m_smith_solihull

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top