Using worksheet_change to add row to named range

wbstadeli

Board Regular
Joined
Mar 11, 2016
Messages
153
Office Version
  1. 365
Platform
  1. Windows
Hi all,

How do i use the worksheet_change event to do the following? My named range is "Timelog".

If first cell of last row in named range "Timelog" is blank, then do nothing, if not blank, then add row to bottom of named range "Timelog". Thanks for your help!
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Call this macro... change Sheet1 to your sheet.

Code:
Sub testnr()
Dim nradd As String
Dim nr As Name
Set nr = ActiveWorkbook.Names.Item("TimeLog")
nradd = Sheet1.Range("TimeLog").AddressLocal
If Trim(Sheet1.Range(Mid(nradd, InStr(nradd, ":") + 1, Len(nradd)))) <> "" Then
nr.RefersTo = "=Sheet1!" & Range(nradd).Offset(1, 0).Address
End If
End Sub
 
Upvote 0
Thanks for your reply Roderick,

Its getting a run time error '1004' (Method 'Range' of object_worksheet failed) on this line. Any suggestions?

Code:
nradd = Sheet1.Range("TimeLog").AddressLocal
 
Upvote 0
Thanks for your reply Roderick,

Its getting a run time error '1004' (Method 'Range' of object_worksheet failed) on this line. Any suggestions?

Code:
nradd = Sheet1.Range("TimeLog").AddressLocal

Hmmm -- is your named range called "TimeLog" and is it on Sheet1??? If not, please correct that.
If everything is correct, try: nradd = Sheet1.Range("TimeLog").address
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,813
Messages
6,121,705
Members
449,048
Latest member
81jamesacct

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