+ Reply to Thread
Results 1 to 5 of 5

Macro to store a table name as a variable

  1. #1
    Registered User
    Join Date
    08-13-2012
    Location
    São Paulo
    MS-Off Ver
    Excel 2007
    Posts
    3

    Macro to store a table name as a variable

    Hi,
    I have a workbook that is linked to different SharePoint sources and each one is stored in a different worksheet.
    I have to create a formula that is based on a table row on all the sheets however, since the table name is different, the table name must change on all the sheets.
    Is there a way for me to capture the table name as a variable so I can change it for the different worksheets?
    On the following code I would like to change the table name “Table_owssvr_413” to the different tables on the worksheets.

    Please Login or Register  to view this content.
    Thanks!

  2. #2
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Macro to store a table name as a variable

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    08-13-2012
    Location
    São Paulo
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Macro to store a table name as a variable

    Thank you Bob!
    It really helps me!!

  4. #4
    Registered User
    Join Date
    10-29-2012
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: Macro to store a table name as a variable

    Quote Originally Posted by Bob Phillips View Post
    Please Login or Register  to view this content.

    I tried applying this method to my code and it doesn't seem to work if I remove the "For Each wSheet".

    Is there a way to run this code without the loop?

    Specific example:

    Dim wSheet As Worksheet
    Dim argh As String


    Sheets("Sheet1").Activate
    For Each wSheet In Worksheets
    With wSheet
    MsgBox .ListObjects(1).name
    argh = .ListObjects(1).name
    ActiveSheet.ListObjects(argh).Range.AutoFilter Field:=9, Criteria1:= _
    "=New", Operator:=xlOr, Criteria2:="=Open"



    End With

    Next wSheet

    End Sub
    Last edited by Jeff2886; 10-29-2012 at 04:48 PM.

  5. #5
    Registered User
    Join Date
    08-13-2012
    Location
    São Paulo
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Macro to store a table name as a variable

    You need to initiate the worksheet if you don't wanna use the loop.

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1