Table not expanding
Results 1 to 7 of 7

Thread: Table not expanding
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Mar 2016
    Posts
    69
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Table not expanding

    I have written the following code that clears a page of data, copies the new data from another book, selects the new region and turns it into a table. It all works except when I add new data it shows up but the added rows do not format alternating row colors like the rest of the table. They are the background color instead.

    Code:
    Sub getData()
    Dim table As ListObject
    Workbooks("Front Desk.xlsm").Sheets("Search Page").Unprotect Password:="*********"
    Workbooks("Front Desk.xlsm").Sheets("Search Page").Range("B14").CurrentRegion.ClearContents
    Workbooks("Intake Data.xlsx").Sheets("Intake Data").Range("A1").CurrentRegion.Copy
    Workbooks("Front Desk.xlsm").Sheets("Search Page").Range("B14").PasteSpecial xlPasteValues
    Set table = Sheet1.ListObjects.Add(xlSrcRange, Workbooks("Front Desk.xlsm").Sheets("Search Page").Range("B14").CurrentRegion, , xlYes)

  2. #2
    Board Regular igold's Avatar
    Join Date
    Jul 2014
    Location
    Delray Beach, FL, USA
    Posts
    2,331
    Post Thanks / Like
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)

    Default Re: Table not expanding

    When you add "new data", are you referring to additional data other than what is initially being dealt with in the above code. If so, what is the code you are using to add the additional data.
    ​igold

    I'm a drinker with a coding problem...

    All code is written with Excel 2010 - Please test all code on a backup copy of your data.


  3. #3
    Board Regular
    Join Date
    Mar 2016
    Posts
    69
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Table not expanding

    Quote Originally Posted by igold View Post
    When you add "new data", are you referring to additional data other than what is initially being dealt with in the above code. If so, what is the code you are using to add the additional data.
    I clear all of the old data (current data) and paste new data in the same place.

  4. #4
    Board Regular
    Join Date
    Mar 2016
    Posts
    69
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Table not expanding

    Quote Originally Posted by igold View Post
    When you add "new data", are you referring to additional data other than what is initially being dealt with in the above code. If so, what is the code you are using to add the additional data.
    Only code listed above.

  5. #5
    Board Regular
    Join Date
    Mar 2016
    Posts
    69
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Table not expanding

    Looks like this issue is related to the fill color of the cells. How do I set the fill color to a range to no fill?

  6. #6
    Board Regular igold's Avatar
    Join Date
    Jul 2014
    Location
    Delray Beach, FL, USA
    Posts
    2,331
    Post Thanks / Like
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)

    Default Re: Table not expanding

    If the name of your Table is Table1 you could use this:

    Code:
    With Range("Table1[#All]").Interior
            .Pattern = xlNone
            .TintAndShade = 0
            .PatternTintAndShade = 0
    End With
    ​igold

    I'm a drinker with a coding problem...

    All code is written with Excel 2010 - Please test all code on a backup copy of your data.


  7. #7
    Board Regular
    Join Date
    Mar 2016
    Posts
    69
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Table not expanding

    Fixed it with this code if anyone is interested. I have seen lots of threads on how to do it with no success. This makes a table that alternates the color but you have to set the interior color to 0 for it to show through on the cells you want and it works when filtered too.

    Code:
    SearchPage.Range("B14").CurrentRegion.ClearContents
    Workbooks(dataBook).Sheets("Intake Data").Range("A1").CurrentRegion.Copy
    SearchPage.Range("B14").PasteSpecial xlPasteValues
    totalrows = SearchPage.Cells(Rows.Count, 7).End(xlUp).Row
    SearchPage.Range("B15:T" & totalrows).Interior.ColorIndex = 0
    SearchPage.ListObjects.Add(xlSrcRange, SearchPage.Range("B14").CurrentRegion, , xlYes).Name = "SearchData"
    Last edited by Kevin0427; Aug 22nd, 2019 at 02:39 PM.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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