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

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
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,224,823
Messages
6,181,179
Members
453,021
Latest member
Justyna P

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