Excel VB Selection Simplification Question

swl681

New Member
Joined
Sep 15, 2011
Messages
8
I am new to Excel VB and have managed to get my code to work, but it seems I could simplify it and also complete the next part of the project as part of the simplification. The part I have working is dragging the formulas in columns T through Y down to the next blank row on the sheets that need it. The primary issue I am having is by not counting the rows I am unable to drag the formula in column C down one additional row. Below is what I have so far and thanks in advance for your time and patience!

Sub Update_Sheets()


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


'Moves selction colums 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("Other Sales Summary").Select


'Moves selction colums 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
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Hi & welcome to MrExcel.
Is this what you want
Code:
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
 
Upvote 0
Unfortunately, that does not work but it is much more efficient then what I had been using, and I think the failing is on my part. I failed to mention that the data is all contained within a table on the respective sheets. When I use the provided VBA, it adds the data at the bottom of the table. It is adding it to the correct columns but the rows are outside of the table.
 
Upvote 0
If it's a table then the formulae should fill down automatically, whenever you add a new row.
 
Upvote 0
I am still unable to get the VBA to work within the table. I think that I need to use the ListObjects("Table4") to get to the correct column and row in the sheet otherwise it does everything outside of the table. I am struggling with the correct syntax to get it working. Your help is appreciated!
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,318
Members
452,634
Latest member
cpostell

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