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)
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
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.
 
Upvote 0
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.
 
Upvote 0
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.
 
Upvote 0
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?
 
Upvote 0
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
 
Upvote 0
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:
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top