View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
FreeBird FreeBird is offline
external usenet poster
 
Posts: 1
Default resequence my worksheets


Hello

If i did catch well, you want to rename the "VBA" name of sheets.
I wrote this below for personal use.
You can simplify it, the important codeline is the last one.


Sub vbp_SheetCodeName_DEMO()
Call vbp_SheetCodeName(ActiveSheet, "test") ', Workbooks("Classeur1"))
End Sub


Sub vbp_SheetCodeName(varSheet As Variant, varSheetCompName As String,
Optional varWorkbook As Variant)
'
If TypeName(varSheet) = "string" Then
Set varSheet = ActiveWorkbook.Sheets(varSheet)
End If

If Not IsMissing(varWorkbook) And TypeName(varWorkbook) = "string"
Then
Set varWorkbook = Workbooks(varWorkbook)
ElseIf IsMissing(varWorkbook) = True Then
Set varWorkbook = ActiveWorkbook
End If

' the important line :
varWorkbook.VBProject.VBComponents(varSheet.CodeNa me).name =
varSheetCompName
End Sub

HTH


--
FreeBird
------------------------------------------------------------------------
FreeBird's Profile: 1701
View this thread:
http://www.thecodecage.com/forumz/sh...d.php?t=193483

http://www.thecodecage.com/forumz