Accessing a named range to insert a value does not work

NSRL

New Member
Joined
Sep 24, 2024
Messages
3
Office Version
  1. Prefer Not To Say
0
I have a piece of code that is trying to overwrite the value in a named range, but I am getting <Object doesn't support this property or method>

Sub CheckStuff()
If Evaluate("Table1RowCount") > Evaluate("Table1LastRowFixed") Then

ActiveWorkbook.Range("Table1LastRowFixed").Value = Evaluate("Table1RowCount")

End If

End Sub

The error occurs at the "ActiveWorkbook.Range" line. Table1RowCount & Table1LastRowFixed are both named ranges with workbook level scope hosting constant values. I am trying to update one of them based on a condition. As you can see the Evaulate function works on both name ranges, but when I try to use the Range to update on of them I am getting the error.
Please note that I have tried "Thisworkbook.Range" and "Range" by itself without much success.

Any help is appreciated.
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Try this way:

VBA Code:
Sub CheckStuff()
    If [Table1RowCount] > [Table1LastRowFixed] Then [Table1LastRowFixed] = [Table1RowCount]
End Sub
 
Upvote 0
Hello JGordon,

Thanks for your response. I tried that piece and now I am getting Object required at the "[Table1LastRowFixed] = [Table1RowCount]" section.
 
Upvote 0
Just learned that it did not work because Range is a property of Worksheet and not of Workbook. I have to use the following.

ActiveWorkbook.Names("Table1LastRowFixed").RefersTo=Evaluate("Table1RowCount")
 
Upvote 0
Solution

Forum statistics

Threads
1,222,558
Messages
6,166,786
Members
452,070
Latest member
patbrunner2001

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