+ Reply to Thread
Results 1 to 6 of 6

I need to save the A1 range of a table to a string...

  1. #1
    Registered User
    Join Date
    03-21-2022
    Location
    Leominster, MA, USA
    MS-Off Ver
    Office 365
    Posts
    10

    I need to save the A1 range of a table to a string...

    I have written code that saves multiple worksheets individually to multiple html pages (using ActiveWorkbook.Publish.Add()). It works great except that there are lots of garbage characters in the resulting html pages. I found that if I convert the tables to ranges, I can eliminate the garbage text

    With the tables present, I am able to use the table name as the "Source" argument (ex: "TableName:TableName")

    When I convert the tables to ranges in VBA, I can no longer refer to the range with the data that used to be in a table.

    Is there a way to set a string variable to the range of the table before I remove it? so that I can refer to the same data in A1 format?

    For example,

    I have a table that occupies A1:G1000 named TABLE1, I want to write code that will output a string value: "A1:G1000" by referencing TABLE1 to a string variable ("TableRange"). This is so that after I convert the table to a range I can populate the ActiveWorkbook.Publish.Add() SOURCE argument with the variable "TableRange" containing "A1:G1000"

    NOTE I've left my code to convert table to range commented out

    Function MakeSaleTableHTM(ProdSheet As String, ProdTable As String, PageTitlePre As String, PageTitlePost As String, PathPre As String, FileName As String, PathExt As String)
    Dim PageTitle As String
    Dim strPath As String
    Dim strSheet As String
    Dim strTable As String

    PageTitle = "" ' PageTitlePre & ProdSheet & PageTitlePost
    strPath = PathPre & FileName & PathExt
    strSheet = ProdSheet
    strTable = ProdTable

    Sheets(strSheet).Activate

    ' convert table to range
    ' Dim xSheet As Worksheet
    ' Dim xList As ListObject
    ' Set xSheet = ActiveWorkbook.ActiveSheet
    ' For Each xList In xSheet.ListObjects
    ' xList.Unlist
    ' Next

    With ActiveWorkbook.PublishObjects.Add(xlSourceRange, _
    strPath, _
    strSheet, _
    strTable, _
    xlHtmlStatic, "PublishToHTML", _
    PageTitle)
    .Publish (True)
    End With
    End Function

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,610

    Re: I need to save the A1 range of a table to a string...

    It'll probably look something like:
    Please Login or Register  to view this content.
    Last edited by protonLeah; 08-25-2022 at 03:40 PM.
    Ben Van Johnson

  3. #3
    Registered User
    Join Date
    03-21-2022
    Location
    Leominster, MA, USA
    MS-Off Ver
    Office 365
    Posts
    10

    Re: I need to save the A1 range of a table to a string...

    What should those variables be declared as? I'm getting errors trying to run

  4. #4
    Registered User
    Join Date
    03-21-2022
    Location
    Leominster, MA, USA
    MS-Off Ver
    Office 365
    Posts
    10

    Re: I need to save the A1 range of a table to a string...

    Also, the x = Range(tblname).Offset(rowoffset:=-1).Resize(rowsize:=tblrows + 1) doesn't return a string, I'm looking for a string like this: "A1:G1000"

  5. #5
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,610

    Re: I need to save the A1 range of a table to a string...

    Created my own test file
    Tested:
    Please Login or Register  to view this content.


    Results:
    Name: Wages, address*: $B$2:$I$52
    Name: Table46, address*: $K$2:$N$12

    *includes table headers
    Last edited by protonLeah; 08-25-2022 at 09:57 PM.

  6. #6
    Registered User
    Join Date
    03-21-2022
    Location
    Leominster, MA, USA
    MS-Off Ver
    Office 365
    Posts
    10

    Re: I need to save the A1 range of a table to a string...

    Thank you! that worked!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 2
    Last Post: 11-21-2020, 04:29 AM
  2. Find short string in reference table within a larger string in lookup table
    By alertall in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 05-16-2019, 10:10 AM
  3. [SOLVED] Searching for unknown text string in a range and then matching it to a reference table
    By the_nibs in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 06-10-2015, 07:26 AM
  4. [SOLVED] Attachments : Save and Rename using Sublect string or File name string
    By checksamir in forum Outlook Programming / VBA / Macros
    Replies: 4
    Last Post: 11-13-2014, 01:13 AM
  5. Find string and save...insert another string
    By twckfa16 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-21-2013, 04:48 PM
  6. Replies: 8
    Last Post: 06-16-2011, 11:49 AM
  7. Pivot Table with string as Data Range
    By eaglesat in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-06-2008, 05:16 PM

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