Codename Null after adding a new sheet

BrighterLater

Board Regular
Joined
Sep 16, 2005
Messages
114
PLease could you comment on this code:


' General purpose Sort Sheet

New_wb.Sheets.Add After:=New_wb.Sheets(1)
ActiveSheet.Name = apsSort

i = New_wb.VBProject.VBComponents.Count


Without the line

i = New_wb.VBProject.VBComponents.Count

Activesheet.codename is NULL

I tried Waiting for it to resolve but it did not.
But it would appear that the VBProject code refreshes the project????

There was a post on Wed 22 Dec 2004 from gbTek.com with a similar query that did not seem to get resloved. Any comments as to what is happening would be most appreciated.
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
When I ran this:

Code:
Sub Test()
    Const apsSort = "Temp"
    Dim New_wb As Workbook
    Set New_wb = Workbooks.Add
    New_wb.Sheets.Add After:=New_wb.Sheets(1)
    ActiveSheet.Name = apsSort
    MsgBox ActiveSheet.CodeName
End Sub

the CodeName popped up. I don't know why it should be null for you.
 
Upvote 0
Thank you for taking the time to answer Andrew.

I guess its some interaction with my other 14,000 lines of code (400 procedures). I had written similar test code too and it works fine for me too in isolation but in the (possibly over)complex context of the rest of my project, believe me, the CodeName is not set and the addition of:

i = New_wb.VBProject.VBComponents.Count

makes it appear.
No-one was able to resolve the issue for the post on Wed 22 Dec 2004 from gbTek.com, I was hoping that someone might shed light on it on the basis that the workaround above nudges it into submission.

Again, thank you for taking the time to run your test. Mike
 
Upvote 0

Forum statistics

Threads
1,203,461
Messages
6,055,559
Members
444,798
Latest member
PAO1609

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