Table not expanding

Kevin0427

Board Regular
Joined
Mar 31, 2016
Messages
69
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)
 

Some videos you may like

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

igold

Well-known Member
Joined
Jul 8, 2014
Messages
2,493
Office Version
365, 2010
Platform
Windows
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.
 

Kevin0427

Board Regular
Joined
Mar 31, 2016
Messages
69
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.
 

Kevin0427

Board Regular
Joined
Mar 31, 2016
Messages
69
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.
 

Kevin0427

Board Regular
Joined
Mar 31, 2016
Messages
69
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?
 

igold

Well-known Member
Joined
Jul 8, 2014
Messages
2,493
Office Version
365, 2010
Platform
Windows
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
 

Kevin0427

Board Regular
Joined
Mar 31, 2016
Messages
69
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:

Watch MrExcel Video

Forum statistics

Threads
1,102,081
Messages
5,484,565
Members
407,455
Latest member
Mishi

This Week's Hot Topics

  • Finding issue in If elseif else with For each Loop
    Finding issue in If elseif else with For each Loop I have tried this below code but i'm getting in Y column filled with W005. Colud you please...
  • MsgBox Error
    Hi Guys, I have the below error show up when i try and run my macro in File1 but works fine if i copy and paste the same code into file2. [ATTACH...
  • CELL FORMAT - IF CONDITION
    My Cell Format is [B]""0.00" Cr". [/B]But in the cell, it is showing 123.00 for editing. (123 is entry figure). (Data imported from other...
  • Show numbers nearly the same
    Is this possible. I have a number that can change very time eg 0.00001234 Then I have a lot of numbers 0.0000001, 0.0000002, 0.00000004...
  • Please i need your help to create formula
    I need a formula in cell B8 to do this >>if b1=1 then multiply ( cell b8) by 10% ,if b1=2 multiply by 20%,if=3 multiply by 30%. Thank you in...
  • Got error while adding column and filter
    Got error while adding column and filter In column Z has some like "Success" and "Error". I want to add column in AA if the Z cell value is...
Top