Run-time error '1004' Name syntax incorrect

tminhv

New Member
Joined
Jun 29, 2023
Messages
16
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

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
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,223,711
Messages
6,174,025
Members
452,542
Latest member
Bricklin

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