Run-time error '1004' Name syntax incorrect

tminhv

New Member
Joined
Jun 29, 2023
Messages
14
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
  3. Web
What does this error mean when I try to run the code? Column A and B are new, and meet criteria. I've tried column B with the full formula, = sign included, and without, as well as with ' in front to show as a string.

View attachment 94442View attachment 94441

I also keep getting this error as well
1688073919437.png
1688074051574.png
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Welcome to the Board!

You have the "sh" in the wrong place. Try this:
VBA Code:
Set rng = sh.Cells(r, "B")
 
Upvote 1
It should just be
VBA Code:
Set rng = sh.Cells(r, "B")
don't wrap it within Range as Cells is already a range.
 
Upvote 1
Thanks that seemed to add it in the name manager, but it refers directly to the cell instead of taking the range inside the cell as the reference.
1688076096469.png

What's showing as the value is what i want to refer to
 
Upvote 0
Deleted as wouldn't work with the sheet name in the string
 
Upvote 0
VBA Code:
Dim MyStr As String, rng as range

MyStr = sh.Cells(r, "B").Value
Set rng = Range(MyStr)
 
Upvote 0
not sure why that didn't work, but if i use my original code, and have it display as a string, '=xxx!$x$#:$x$#, it works now, thank you for your help
 
Upvote 0

Forum statistics

Threads
1,215,410
Messages
6,124,749
Members
449,186
Latest member
HBryant

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