multiple VBA

jojowiththaflow

New Member
Joined
Jan 17, 2019
Messages
6
Is there a way to get this code to apply to multiple cells - say C2 through C9?

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rInterest As Range
Set rInterest = Range("H2")
Dim rTotal As Range
Set rTotal = Range("C2")
Dim rList As Range
Set rList = Range("J1")
Dim lRow As Long
' ignore multiple changes, eg, deleting cell contents
If Target.Cells.Count > 1 Then Exit Sub
'Only monitor the cell of interest
If Intersect(Target, rInterest) Is Nothing Then Exit Sub
' only look at numbers
If Not IsNumeric(rInterest.Value) Then Exit Sub
Application.EnableEvents = False
rList.Resize(, 2).Value = Array("Data", "Time Stamp")
lRow = Cells(Rows.Count, rList.Column).End(xlUp).Row + 1
Cells(lRow, rList.Column).Value = rInterest.Value
Cells(lRow, rList.Column + 1).Value = Now
rTotal.Value = rTotal.Value + rInterest.Value
rInterest.Value = ""
rInterest.Select
Application.EnableEvents = True

End Sub
 
Awesome! Thank you very much for your help on this, and sorry about not being clear with what I was looking for. This is the first time I've tried using VBA.
 
Upvote 0

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Awesome! Thank you very much for your help on this

you are welcome!

and sorry about not being clear with what I was looking for. This is the first time I've tried using VBA.
No worries! We see that you are new here. Just trying to save you (and your responders) from some potential headaches down the road.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,323
Members
452,635
Latest member
laura12345

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