Offset ActiveSheet.Name into ActiveWorkbook.Names

Fubi

New Member
Joined
Jul 27, 2022
Messages
5
Office Version
  1. 365
Hello members!


When i look inside the name manager the formula is wrapped into apostrof's.
Because of that my vba code below doesn't work. Without apostrof's the vba code won't even run.

Can someone show me a solution for this problem?

VBA Code:
Sub Productieprint()

    ActiveWorkbook.Names("DynPrint").RefersToR1C1 = "=OFFSET('" & ActiveSheet.Name & "'!R2C6,0,0,COUNTA('" & ActiveSheet.Name & "'!C6),4)"
    Application.CutCopyMode = False

    Sheets(ActiveSheet.Name).PageSetup.Orientation = xlPortrait

    ActiveWorkbook.Worksheets(ActiveSheet.Name).Names("Print_Area").RefersToR1C1 = "=DynPrint"

End Sub

Kind regards
 

Attachments

  • 1664541801643.png
    1664541801643.png
    312 bytes · Views: 5

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Good to hear you got the solution.

If you would like to post the solution then it is perfectly fine to mark your post as the solution to help future readers. Otherwise, please do not mark a post that doesn't contain a solution.
 
Upvote 0
I know what you're trying to say. Actually what Jeffrey suggested did they trick. Thanks everyone.
 
Upvote 0
In that case feel free to mark post#4 as the solution.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,333
Members
452,636
Latest member
laura12345

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