Hi all,
How do I change a range name definition at run-time?
For example, in Sheet 1, I have a range named “Goober” which is defined as $A$20:$A$34. If the user clears or changes A34 to blank, how do I redefine the range name “Goober” to equal $A$20:$A$33?
This is what I have started on:
Public Sub Worksheet_Change(ByVal Target As Range) Dim yopapa As Integer Dim yomama As Integer For Each cell In Range("a20:a34") If cell.Value "" Then yopapa = yopapa = yopapa + 1 Next yomama = 20 + yopapa ThisWorkbook.Names.Add Name:="Goober", RefersToR1C1:="='Sheet1'!R20C1:R'yomama'C1" End Sub
I keep getting an error on the ‘Thisworkbook.Names.Add….’ line. Almost like the syntax is not right or something. Any ideas for my rudimentary code?
Thanks,