VBA Script

camper1337

New Member
Joined
Jan 7, 2018
Messages
6
I have a script that I have written. The script works well, but only on Sheet 1. If I enter data into sheets 2-5, the end result of the vba still goes to Sheet 1. I'd like to make the script work individually on each sheet. Thanks in advance. Code Below.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
   ''Do something only if the value changes in cell B9
   If Target.Address = Range("B9").Address Then
   Range("C8").Value = Range("C9")
   If Target.Address = "$B$9" Then
      ''Look at the full list below the Target title
      With ThisWorkbook.Names("Reading_Date").RefersToRange.CurrentRegion
         ''Look at the cell at the bottom of the list
         With .Offset(.Rows.Count, 0).Resize(1, 1)
             ''Enter the current time in the cell
             .Value = Format(Date, "Short Date")
             ''Enter the new value to the right of the time
             .Offset(0, 1).Value = Target.Value
             .Offset(0, 2).Value = Range("B11")
             .Offset(0, 3).Value = Range("B20")
          End With
      
      End With
   End If
   End If
End Sub
 
How exactly have you defined the named range 'Reading_Date'?
 
Upvote 0

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
How exactly have you defined the named range 'Reading_Date'?

All indications from the previous posts is that it is only defined for sheet 1. I think the name manager needs some tweaking.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,331
Members
452,636
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