Excel Sheet Index Identify by Unique Number in a VBA Macro?












1















Two working macro’s for Checklists & Templates below



Workbook = Steve
Sheet within workbook has been allocated 15286



I need to add sheets to a macro and need to know how to locate what I assume is a unique _number, so that I can perform the same routine on a new data sheet within Same workbook



The workbook contains the same macro, several times the only difference being a number



Eg: Checklists =



Sub PublishChecklists()
'
' Saves htm version of Sheet on Server
'
Range("M8:M2000").Select
Selection.Font.ColorIndex = 0
Selection.autofilter Field:=7, Criteria1:=Array("<>Exc")
Columns("A:J").Select
Selection.EntireColumn.Hidden = True
With ActiveWorkbook.PublishObjects("Steve_**15826**")
.Title = "CHECKLIST LIST"
.Filename = "\f:dataWorkChecklists.htm"
.Publish (True)
.AutoRepublish = False
End With
ChDir "F:dataWorkToday's Work"
Columns("A:J").Select
Selection.EntireColumn.Hidden = False
Selection.autofilter Field:=7
Columns("H:H").Select
Selection.EntireColumn.Hidden = True
Range("L8").Select

End Sub


Templates =



Sub PublishTemplates()
'
' Saves htm version of Sheet on Server
'
Range("M8:M2000").Select
Selection.Font.ColorIndex = 0
Selection.autofilter Field:=7, Criteria1:=Array("<>Exc")
Columns("A:J").Select
Selection.EntireColumn.Hidden = True
With ActiveWorkbook.PublishObjects("Steve_**3496**")
.Title = "TEMPLATES LIST"
.Filename = "\f:dataWorkTemplates.htm"
.Publish (True)
.AutoRepublish = False
End With
ChDir "F:dataWorkToday's Work"
Columns("A:J").Select
Selection.EntireColumn.Hidden = False
Selection.autofilter Field:=7
Columns("H:H").Select
Selection.EntireColumn.Hidden = True
Range("L8").Select

End Sub


--



Both work, the only thing that appears different is the "15286" & "3486", as they are different sheets?
if I add a new sheet, I need to know, how I can locate the "3486" number bit as it will be a different number for a new sheet



I inherited the code and have no idea how the were found in order for them to be placed in the above code



Many thanks for your time



Steve










share|improve this question





























    1















    Two working macro’s for Checklists & Templates below



    Workbook = Steve
    Sheet within workbook has been allocated 15286



    I need to add sheets to a macro and need to know how to locate what I assume is a unique _number, so that I can perform the same routine on a new data sheet within Same workbook



    The workbook contains the same macro, several times the only difference being a number



    Eg: Checklists =



    Sub PublishChecklists()
    '
    ' Saves htm version of Sheet on Server
    '
    Range("M8:M2000").Select
    Selection.Font.ColorIndex = 0
    Selection.autofilter Field:=7, Criteria1:=Array("<>Exc")
    Columns("A:J").Select
    Selection.EntireColumn.Hidden = True
    With ActiveWorkbook.PublishObjects("Steve_**15826**")
    .Title = "CHECKLIST LIST"
    .Filename = "\f:dataWorkChecklists.htm"
    .Publish (True)
    .AutoRepublish = False
    End With
    ChDir "F:dataWorkToday's Work"
    Columns("A:J").Select
    Selection.EntireColumn.Hidden = False
    Selection.autofilter Field:=7
    Columns("H:H").Select
    Selection.EntireColumn.Hidden = True
    Range("L8").Select

    End Sub


    Templates =



    Sub PublishTemplates()
    '
    ' Saves htm version of Sheet on Server
    '
    Range("M8:M2000").Select
    Selection.Font.ColorIndex = 0
    Selection.autofilter Field:=7, Criteria1:=Array("<>Exc")
    Columns("A:J").Select
    Selection.EntireColumn.Hidden = True
    With ActiveWorkbook.PublishObjects("Steve_**3496**")
    .Title = "TEMPLATES LIST"
    .Filename = "\f:dataWorkTemplates.htm"
    .Publish (True)
    .AutoRepublish = False
    End With
    ChDir "F:dataWorkToday's Work"
    Columns("A:J").Select
    Selection.EntireColumn.Hidden = False
    Selection.autofilter Field:=7
    Columns("H:H").Select
    Selection.EntireColumn.Hidden = True
    Range("L8").Select

    End Sub


    --



    Both work, the only thing that appears different is the "15286" & "3486", as they are different sheets?
    if I add a new sheet, I need to know, how I can locate the "3486" number bit as it will be a different number for a new sheet



    I inherited the code and have no idea how the were found in order for them to be placed in the above code



    Many thanks for your time



    Steve










    share|improve this question



























      1












      1








      1








      Two working macro’s for Checklists & Templates below



      Workbook = Steve
      Sheet within workbook has been allocated 15286



      I need to add sheets to a macro and need to know how to locate what I assume is a unique _number, so that I can perform the same routine on a new data sheet within Same workbook



      The workbook contains the same macro, several times the only difference being a number



      Eg: Checklists =



      Sub PublishChecklists()
      '
      ' Saves htm version of Sheet on Server
      '
      Range("M8:M2000").Select
      Selection.Font.ColorIndex = 0
      Selection.autofilter Field:=7, Criteria1:=Array("<>Exc")
      Columns("A:J").Select
      Selection.EntireColumn.Hidden = True
      With ActiveWorkbook.PublishObjects("Steve_**15826**")
      .Title = "CHECKLIST LIST"
      .Filename = "\f:dataWorkChecklists.htm"
      .Publish (True)
      .AutoRepublish = False
      End With
      ChDir "F:dataWorkToday's Work"
      Columns("A:J").Select
      Selection.EntireColumn.Hidden = False
      Selection.autofilter Field:=7
      Columns("H:H").Select
      Selection.EntireColumn.Hidden = True
      Range("L8").Select

      End Sub


      Templates =



      Sub PublishTemplates()
      '
      ' Saves htm version of Sheet on Server
      '
      Range("M8:M2000").Select
      Selection.Font.ColorIndex = 0
      Selection.autofilter Field:=7, Criteria1:=Array("<>Exc")
      Columns("A:J").Select
      Selection.EntireColumn.Hidden = True
      With ActiveWorkbook.PublishObjects("Steve_**3496**")
      .Title = "TEMPLATES LIST"
      .Filename = "\f:dataWorkTemplates.htm"
      .Publish (True)
      .AutoRepublish = False
      End With
      ChDir "F:dataWorkToday's Work"
      Columns("A:J").Select
      Selection.EntireColumn.Hidden = False
      Selection.autofilter Field:=7
      Columns("H:H").Select
      Selection.EntireColumn.Hidden = True
      Range("L8").Select

      End Sub


      --



      Both work, the only thing that appears different is the "15286" & "3486", as they are different sheets?
      if I add a new sheet, I need to know, how I can locate the "3486" number bit as it will be a different number for a new sheet



      I inherited the code and have no idea how the were found in order for them to be placed in the above code



      Many thanks for your time



      Steve










      share|improve this question
















      Two working macro’s for Checklists & Templates below



      Workbook = Steve
      Sheet within workbook has been allocated 15286



      I need to add sheets to a macro and need to know how to locate what I assume is a unique _number, so that I can perform the same routine on a new data sheet within Same workbook



      The workbook contains the same macro, several times the only difference being a number



      Eg: Checklists =



      Sub PublishChecklists()
      '
      ' Saves htm version of Sheet on Server
      '
      Range("M8:M2000").Select
      Selection.Font.ColorIndex = 0
      Selection.autofilter Field:=7, Criteria1:=Array("<>Exc")
      Columns("A:J").Select
      Selection.EntireColumn.Hidden = True
      With ActiveWorkbook.PublishObjects("Steve_**15826**")
      .Title = "CHECKLIST LIST"
      .Filename = "\f:dataWorkChecklists.htm"
      .Publish (True)
      .AutoRepublish = False
      End With
      ChDir "F:dataWorkToday's Work"
      Columns("A:J").Select
      Selection.EntireColumn.Hidden = False
      Selection.autofilter Field:=7
      Columns("H:H").Select
      Selection.EntireColumn.Hidden = True
      Range("L8").Select

      End Sub


      Templates =



      Sub PublishTemplates()
      '
      ' Saves htm version of Sheet on Server
      '
      Range("M8:M2000").Select
      Selection.Font.ColorIndex = 0
      Selection.autofilter Field:=7, Criteria1:=Array("<>Exc")
      Columns("A:J").Select
      Selection.EntireColumn.Hidden = True
      With ActiveWorkbook.PublishObjects("Steve_**3496**")
      .Title = "TEMPLATES LIST"
      .Filename = "\f:dataWorkTemplates.htm"
      .Publish (True)
      .AutoRepublish = False
      End With
      ChDir "F:dataWorkToday's Work"
      Columns("A:J").Select
      Selection.EntireColumn.Hidden = False
      Selection.autofilter Field:=7
      Columns("H:H").Select
      Selection.EntireColumn.Hidden = True
      Range("L8").Select

      End Sub


      --



      Both work, the only thing that appears different is the "15286" & "3486", as they are different sheets?
      if I add a new sheet, I need to know, how I can locate the "3486" number bit as it will be a different number for a new sheet



      I inherited the code and have no idea how the were found in order for them to be placed in the above code



      Many thanks for your time



      Steve







      excel vba excel-vba






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 12 '18 at 16:53









      EvR

      1,2342313




      1,2342313










      asked Nov 12 '18 at 14:11









      Steve WhitingSteve Whiting

      61




      61
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Just call the same procedure and pass the number to it as an argument.



          Your procedure would be similar to:



          Sub PublishLists(RefNumber As Long, Title As String)

          '...
          '...
          '...
          With ActiveWorkbook.PublishObjects("Steve_**" & RefNumber & "**")
          .Title = Title & " LIST"

          '...
          '...
          '...

          End Sub


          You'd then call the procedure and pass the number and title to it:



          Sub Test()

          PublishLists 15826, "CHECKLIST"
          PublishLists 3496, "TEMPLATES"

          End Sub


          Edit:

          I haven't tested any of your code - have just adjusted to accept passed arguments and remove anything that says Select or Selection.

          The Test procedure here would execute PublishLists twice using different arguments each time.



          Public Sub Test()

          'The three values are passed to the "PublishLists" procedure.
          'First line would PublishObjects to "Steve_**15826**" and second to "Steve_**3496**"

          PublishLists 15826, "CHECKLIST ", "Checklists.htm"
          PublishLists 3496, "TEMPLATES", "Templates.htm"

          End Sub

          Sub PublishLists(RefNumber As Long, Title As String, SaveFile As String)

          With ThisWorkbook.Worksheets("Sheet1") 'Update sheet name as required.
          With .Range("M8:M2000")
          .Font.ColorIndex = 0
          .AutoFilter Field:=7, Criteria1:=Array("<>Exc")
          End With
          .Columns("A:J").Hidden = True
          End With

          With ThisWorkbook.PublishObjects("Steve_**" & RefNumber & "**") 'RefNumber variable passed to name.
          .Title = Title & " LIST" 'Title variable passed to title.
          .Filename = "\f:dataWork" & SaveFile 'SaveFile variable passed to FileName
          .Publish (True)
          .AutoRepublish = False
          End With

          With ThisWorkbook.Worksheets("Sheet1") 'Update sheet name as required.
          With .Columns("A:J")
          .Hidden = False
          .AutoFilter Field:=7
          End With
          .Columns("H:H").Hidden = True
          .Range("L8").Select 'The only cell that is selected.
          End With

          End Sub





          share|improve this answer


























          • thanks, not sure that really answers my question though :-) - how is ANY sheet allocated a number and HOW can I find out what that new sheets number would be, the numbers 3496 & 15826 are already in the code. If I create a new sheet, how can I find out what number (as above would be. I'm assuming 15826 & 3496 are generated from SOMEWHERE as the seem to be very specific. I hope that makes sense. as this seems to be a very difficult question for people to grasp.

            – Steve Whiting
            Nov 12 '18 at 16:15











          • I'll update my code to show how it would work in the context of your code. I doubt anyone can answer where the numbers come from - it's not Excel that creates those numbers. They must have been either manually assigned, or the pattern has been coded into VBA/some other package to create them.

            – Darren Bartrup-Cook
            Nov 12 '18 at 16:18











          • Just need to reiterate - I'm assuming 15826 & 3496 are generated from SOMEWHERE - they will be, but not automatically by Excel. These numbers are generated by something your system is using.

            – Darren Bartrup-Cook
            Nov 12 '18 at 16:32













          • Thanks Darren, All I can add is the resulting htm file is hosted on SharePoint 2010 server if that's any help. Although it doesn't help that much it IS good to know there's a somewhat random element to this

            – Steve Whiting
            Nov 12 '18 at 19:14











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53263948%2fexcel-sheet-index-identify-by-unique-number-in-a-vba-macro%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Just call the same procedure and pass the number to it as an argument.



          Your procedure would be similar to:



          Sub PublishLists(RefNumber As Long, Title As String)

          '...
          '...
          '...
          With ActiveWorkbook.PublishObjects("Steve_**" & RefNumber & "**")
          .Title = Title & " LIST"

          '...
          '...
          '...

          End Sub


          You'd then call the procedure and pass the number and title to it:



          Sub Test()

          PublishLists 15826, "CHECKLIST"
          PublishLists 3496, "TEMPLATES"

          End Sub


          Edit:

          I haven't tested any of your code - have just adjusted to accept passed arguments and remove anything that says Select or Selection.

          The Test procedure here would execute PublishLists twice using different arguments each time.



          Public Sub Test()

          'The three values are passed to the "PublishLists" procedure.
          'First line would PublishObjects to "Steve_**15826**" and second to "Steve_**3496**"

          PublishLists 15826, "CHECKLIST ", "Checklists.htm"
          PublishLists 3496, "TEMPLATES", "Templates.htm"

          End Sub

          Sub PublishLists(RefNumber As Long, Title As String, SaveFile As String)

          With ThisWorkbook.Worksheets("Sheet1") 'Update sheet name as required.
          With .Range("M8:M2000")
          .Font.ColorIndex = 0
          .AutoFilter Field:=7, Criteria1:=Array("<>Exc")
          End With
          .Columns("A:J").Hidden = True
          End With

          With ThisWorkbook.PublishObjects("Steve_**" & RefNumber & "**") 'RefNumber variable passed to name.
          .Title = Title & " LIST" 'Title variable passed to title.
          .Filename = "\f:dataWork" & SaveFile 'SaveFile variable passed to FileName
          .Publish (True)
          .AutoRepublish = False
          End With

          With ThisWorkbook.Worksheets("Sheet1") 'Update sheet name as required.
          With .Columns("A:J")
          .Hidden = False
          .AutoFilter Field:=7
          End With
          .Columns("H:H").Hidden = True
          .Range("L8").Select 'The only cell that is selected.
          End With

          End Sub





          share|improve this answer


























          • thanks, not sure that really answers my question though :-) - how is ANY sheet allocated a number and HOW can I find out what that new sheets number would be, the numbers 3496 & 15826 are already in the code. If I create a new sheet, how can I find out what number (as above would be. I'm assuming 15826 & 3496 are generated from SOMEWHERE as the seem to be very specific. I hope that makes sense. as this seems to be a very difficult question for people to grasp.

            – Steve Whiting
            Nov 12 '18 at 16:15











          • I'll update my code to show how it would work in the context of your code. I doubt anyone can answer where the numbers come from - it's not Excel that creates those numbers. They must have been either manually assigned, or the pattern has been coded into VBA/some other package to create them.

            – Darren Bartrup-Cook
            Nov 12 '18 at 16:18











          • Just need to reiterate - I'm assuming 15826 & 3496 are generated from SOMEWHERE - they will be, but not automatically by Excel. These numbers are generated by something your system is using.

            – Darren Bartrup-Cook
            Nov 12 '18 at 16:32













          • Thanks Darren, All I can add is the resulting htm file is hosted on SharePoint 2010 server if that's any help. Although it doesn't help that much it IS good to know there's a somewhat random element to this

            – Steve Whiting
            Nov 12 '18 at 19:14
















          0














          Just call the same procedure and pass the number to it as an argument.



          Your procedure would be similar to:



          Sub PublishLists(RefNumber As Long, Title As String)

          '...
          '...
          '...
          With ActiveWorkbook.PublishObjects("Steve_**" & RefNumber & "**")
          .Title = Title & " LIST"

          '...
          '...
          '...

          End Sub


          You'd then call the procedure and pass the number and title to it:



          Sub Test()

          PublishLists 15826, "CHECKLIST"
          PublishLists 3496, "TEMPLATES"

          End Sub


          Edit:

          I haven't tested any of your code - have just adjusted to accept passed arguments and remove anything that says Select or Selection.

          The Test procedure here would execute PublishLists twice using different arguments each time.



          Public Sub Test()

          'The three values are passed to the "PublishLists" procedure.
          'First line would PublishObjects to "Steve_**15826**" and second to "Steve_**3496**"

          PublishLists 15826, "CHECKLIST ", "Checklists.htm"
          PublishLists 3496, "TEMPLATES", "Templates.htm"

          End Sub

          Sub PublishLists(RefNumber As Long, Title As String, SaveFile As String)

          With ThisWorkbook.Worksheets("Sheet1") 'Update sheet name as required.
          With .Range("M8:M2000")
          .Font.ColorIndex = 0
          .AutoFilter Field:=7, Criteria1:=Array("<>Exc")
          End With
          .Columns("A:J").Hidden = True
          End With

          With ThisWorkbook.PublishObjects("Steve_**" & RefNumber & "**") 'RefNumber variable passed to name.
          .Title = Title & " LIST" 'Title variable passed to title.
          .Filename = "\f:dataWork" & SaveFile 'SaveFile variable passed to FileName
          .Publish (True)
          .AutoRepublish = False
          End With

          With ThisWorkbook.Worksheets("Sheet1") 'Update sheet name as required.
          With .Columns("A:J")
          .Hidden = False
          .AutoFilter Field:=7
          End With
          .Columns("H:H").Hidden = True
          .Range("L8").Select 'The only cell that is selected.
          End With

          End Sub





          share|improve this answer


























          • thanks, not sure that really answers my question though :-) - how is ANY sheet allocated a number and HOW can I find out what that new sheets number would be, the numbers 3496 & 15826 are already in the code. If I create a new sheet, how can I find out what number (as above would be. I'm assuming 15826 & 3496 are generated from SOMEWHERE as the seem to be very specific. I hope that makes sense. as this seems to be a very difficult question for people to grasp.

            – Steve Whiting
            Nov 12 '18 at 16:15











          • I'll update my code to show how it would work in the context of your code. I doubt anyone can answer where the numbers come from - it's not Excel that creates those numbers. They must have been either manually assigned, or the pattern has been coded into VBA/some other package to create them.

            – Darren Bartrup-Cook
            Nov 12 '18 at 16:18











          • Just need to reiterate - I'm assuming 15826 & 3496 are generated from SOMEWHERE - they will be, but not automatically by Excel. These numbers are generated by something your system is using.

            – Darren Bartrup-Cook
            Nov 12 '18 at 16:32













          • Thanks Darren, All I can add is the resulting htm file is hosted on SharePoint 2010 server if that's any help. Although it doesn't help that much it IS good to know there's a somewhat random element to this

            – Steve Whiting
            Nov 12 '18 at 19:14














          0












          0








          0







          Just call the same procedure and pass the number to it as an argument.



          Your procedure would be similar to:



          Sub PublishLists(RefNumber As Long, Title As String)

          '...
          '...
          '...
          With ActiveWorkbook.PublishObjects("Steve_**" & RefNumber & "**")
          .Title = Title & " LIST"

          '...
          '...
          '...

          End Sub


          You'd then call the procedure and pass the number and title to it:



          Sub Test()

          PublishLists 15826, "CHECKLIST"
          PublishLists 3496, "TEMPLATES"

          End Sub


          Edit:

          I haven't tested any of your code - have just adjusted to accept passed arguments and remove anything that says Select or Selection.

          The Test procedure here would execute PublishLists twice using different arguments each time.



          Public Sub Test()

          'The three values are passed to the "PublishLists" procedure.
          'First line would PublishObjects to "Steve_**15826**" and second to "Steve_**3496**"

          PublishLists 15826, "CHECKLIST ", "Checklists.htm"
          PublishLists 3496, "TEMPLATES", "Templates.htm"

          End Sub

          Sub PublishLists(RefNumber As Long, Title As String, SaveFile As String)

          With ThisWorkbook.Worksheets("Sheet1") 'Update sheet name as required.
          With .Range("M8:M2000")
          .Font.ColorIndex = 0
          .AutoFilter Field:=7, Criteria1:=Array("<>Exc")
          End With
          .Columns("A:J").Hidden = True
          End With

          With ThisWorkbook.PublishObjects("Steve_**" & RefNumber & "**") 'RefNumber variable passed to name.
          .Title = Title & " LIST" 'Title variable passed to title.
          .Filename = "\f:dataWork" & SaveFile 'SaveFile variable passed to FileName
          .Publish (True)
          .AutoRepublish = False
          End With

          With ThisWorkbook.Worksheets("Sheet1") 'Update sheet name as required.
          With .Columns("A:J")
          .Hidden = False
          .AutoFilter Field:=7
          End With
          .Columns("H:H").Hidden = True
          .Range("L8").Select 'The only cell that is selected.
          End With

          End Sub





          share|improve this answer















          Just call the same procedure and pass the number to it as an argument.



          Your procedure would be similar to:



          Sub PublishLists(RefNumber As Long, Title As String)

          '...
          '...
          '...
          With ActiveWorkbook.PublishObjects("Steve_**" & RefNumber & "**")
          .Title = Title & " LIST"

          '...
          '...
          '...

          End Sub


          You'd then call the procedure and pass the number and title to it:



          Sub Test()

          PublishLists 15826, "CHECKLIST"
          PublishLists 3496, "TEMPLATES"

          End Sub


          Edit:

          I haven't tested any of your code - have just adjusted to accept passed arguments and remove anything that says Select or Selection.

          The Test procedure here would execute PublishLists twice using different arguments each time.



          Public Sub Test()

          'The three values are passed to the "PublishLists" procedure.
          'First line would PublishObjects to "Steve_**15826**" and second to "Steve_**3496**"

          PublishLists 15826, "CHECKLIST ", "Checklists.htm"
          PublishLists 3496, "TEMPLATES", "Templates.htm"

          End Sub

          Sub PublishLists(RefNumber As Long, Title As String, SaveFile As String)

          With ThisWorkbook.Worksheets("Sheet1") 'Update sheet name as required.
          With .Range("M8:M2000")
          .Font.ColorIndex = 0
          .AutoFilter Field:=7, Criteria1:=Array("<>Exc")
          End With
          .Columns("A:J").Hidden = True
          End With

          With ThisWorkbook.PublishObjects("Steve_**" & RefNumber & "**") 'RefNumber variable passed to name.
          .Title = Title & " LIST" 'Title variable passed to title.
          .Filename = "\f:dataWork" & SaveFile 'SaveFile variable passed to FileName
          .Publish (True)
          .AutoRepublish = False
          End With

          With ThisWorkbook.Worksheets("Sheet1") 'Update sheet name as required.
          With .Columns("A:J")
          .Hidden = False
          .AutoFilter Field:=7
          End With
          .Columns("H:H").Hidden = True
          .Range("L8").Select 'The only cell that is selected.
          End With

          End Sub






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 12 '18 at 16:30

























          answered Nov 12 '18 at 15:08









          Darren Bartrup-CookDarren Bartrup-Cook

          13.8k11432




          13.8k11432













          • thanks, not sure that really answers my question though :-) - how is ANY sheet allocated a number and HOW can I find out what that new sheets number would be, the numbers 3496 & 15826 are already in the code. If I create a new sheet, how can I find out what number (as above would be. I'm assuming 15826 & 3496 are generated from SOMEWHERE as the seem to be very specific. I hope that makes sense. as this seems to be a very difficult question for people to grasp.

            – Steve Whiting
            Nov 12 '18 at 16:15











          • I'll update my code to show how it would work in the context of your code. I doubt anyone can answer where the numbers come from - it's not Excel that creates those numbers. They must have been either manually assigned, or the pattern has been coded into VBA/some other package to create them.

            – Darren Bartrup-Cook
            Nov 12 '18 at 16:18











          • Just need to reiterate - I'm assuming 15826 & 3496 are generated from SOMEWHERE - they will be, but not automatically by Excel. These numbers are generated by something your system is using.

            – Darren Bartrup-Cook
            Nov 12 '18 at 16:32













          • Thanks Darren, All I can add is the resulting htm file is hosted on SharePoint 2010 server if that's any help. Although it doesn't help that much it IS good to know there's a somewhat random element to this

            – Steve Whiting
            Nov 12 '18 at 19:14



















          • thanks, not sure that really answers my question though :-) - how is ANY sheet allocated a number and HOW can I find out what that new sheets number would be, the numbers 3496 & 15826 are already in the code. If I create a new sheet, how can I find out what number (as above would be. I'm assuming 15826 & 3496 are generated from SOMEWHERE as the seem to be very specific. I hope that makes sense. as this seems to be a very difficult question for people to grasp.

            – Steve Whiting
            Nov 12 '18 at 16:15











          • I'll update my code to show how it would work in the context of your code. I doubt anyone can answer where the numbers come from - it's not Excel that creates those numbers. They must have been either manually assigned, or the pattern has been coded into VBA/some other package to create them.

            – Darren Bartrup-Cook
            Nov 12 '18 at 16:18











          • Just need to reiterate - I'm assuming 15826 & 3496 are generated from SOMEWHERE - they will be, but not automatically by Excel. These numbers are generated by something your system is using.

            – Darren Bartrup-Cook
            Nov 12 '18 at 16:32













          • Thanks Darren, All I can add is the resulting htm file is hosted on SharePoint 2010 server if that's any help. Although it doesn't help that much it IS good to know there's a somewhat random element to this

            – Steve Whiting
            Nov 12 '18 at 19:14

















          thanks, not sure that really answers my question though :-) - how is ANY sheet allocated a number and HOW can I find out what that new sheets number would be, the numbers 3496 & 15826 are already in the code. If I create a new sheet, how can I find out what number (as above would be. I'm assuming 15826 & 3496 are generated from SOMEWHERE as the seem to be very specific. I hope that makes sense. as this seems to be a very difficult question for people to grasp.

          – Steve Whiting
          Nov 12 '18 at 16:15





          thanks, not sure that really answers my question though :-) - how is ANY sheet allocated a number and HOW can I find out what that new sheets number would be, the numbers 3496 & 15826 are already in the code. If I create a new sheet, how can I find out what number (as above would be. I'm assuming 15826 & 3496 are generated from SOMEWHERE as the seem to be very specific. I hope that makes sense. as this seems to be a very difficult question for people to grasp.

          – Steve Whiting
          Nov 12 '18 at 16:15













          I'll update my code to show how it would work in the context of your code. I doubt anyone can answer where the numbers come from - it's not Excel that creates those numbers. They must have been either manually assigned, or the pattern has been coded into VBA/some other package to create them.

          – Darren Bartrup-Cook
          Nov 12 '18 at 16:18





          I'll update my code to show how it would work in the context of your code. I doubt anyone can answer where the numbers come from - it's not Excel that creates those numbers. They must have been either manually assigned, or the pattern has been coded into VBA/some other package to create them.

          – Darren Bartrup-Cook
          Nov 12 '18 at 16:18













          Just need to reiterate - I'm assuming 15826 & 3496 are generated from SOMEWHERE - they will be, but not automatically by Excel. These numbers are generated by something your system is using.

          – Darren Bartrup-Cook
          Nov 12 '18 at 16:32







          Just need to reiterate - I'm assuming 15826 & 3496 are generated from SOMEWHERE - they will be, but not automatically by Excel. These numbers are generated by something your system is using.

          – Darren Bartrup-Cook
          Nov 12 '18 at 16:32















          Thanks Darren, All I can add is the resulting htm file is hosted on SharePoint 2010 server if that's any help. Although it doesn't help that much it IS good to know there's a somewhat random element to this

          – Steve Whiting
          Nov 12 '18 at 19:14





          Thanks Darren, All I can add is the resulting htm file is hosted on SharePoint 2010 server if that's any help. Although it doesn't help that much it IS good to know there's a somewhat random element to this

          – Steve Whiting
          Nov 12 '18 at 19:14


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53263948%2fexcel-sheet-index-identify-by-unique-number-in-a-vba-macro%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Coverage of Google Street View

          Full-time equivalent

          Surfing