Unable to Update a Row in a Table through VB

swl681

New Member
Joined
Sep 15, 2011
Messages
8
I have a spreadsheet that contains a table, and I am working with a VB macro to update a row each week. The below works for the correct columns and rows, but it updates the columns outside of the table. I have tried with no success to utilize ListObjects("Table4") to make the range available within the table but have failed miserably. Any direction would be much appreciated!


Sub Update_Sheets()
With Sheets("Sales Summary")​
.Range("T" & Rows.Count).End(xlUp).Resize(2, 6).FillDown
.Range("C" & Rows.Count).End(xlUp).Resize(2).FillDown​
End With​
With Sheets("Other Sales Summary")​
.Range("T" & Rows.Count).End(xlUp).Resize(2, 6).FillDown
.Range("C" & Rows.Count).End(xlUp).Resize(2).FillDown​
End With​
End Sub
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Is this working?

Code:
Sub Update_Sheets()


Dim lastrow As Long


With Sheets("Sales Summary")
lastrow = .ListObjects("Table4").Range.Columns(1).Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
.Range("T" & lastrow).Resize(2, 6).FillDown
.Range("C" & lastrow).Resize(2).FillDown
End With


End Sub
 
Upvote 0
No, when running the above code, it inserts a row at the bottom of the table above the totals row.

This is the code I started with and it does work but I am trying to simplify and remove the selects.

Sub Update_Sheets()


'Selects the required sheet
Sheets("EVYC Sales Summary").Select


'Moves selection columns needing update
Range("T2").Select


'Moves selection to last entry
Selection.End(xlDown).Select
Range(Selection, Selection.End(xlToRight)).Select


'This works as long as the active cells is selected
Range(Selection.Offset(1, 0), Selection).FillDown

'Selects the required sheet
Sheets("Seasonal Sales Summary").Select


'Moves selection columns needing update
Range("T2").Select


'Moves selection to last entry
Selection.End(xlDown).Select
Range(Selection, Selection.End(xlToRight)).Select


'This works as long as the active cells is selected
Range(Selection.Offset(1, 0), Selection).FillDown


End Sub
 
Last edited:
Upvote 0
Got it to work with the below code, thank you for your help!

Sub Update_Sheet()
With Sheets("Sales Summary")
.Range("T2").End(xlDown).Resize(2, 6).FillDown​
.Range("T2").End(xlDown).Offset(0, -17).FillDown​
End With​

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,617
Messages
6,120,541
Members
448,970
Latest member
kennimack

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