VBA Autofill Formula Issue

ItalianPlatinum

Well-known Member
Joined
Mar 23, 2017
Messages
793
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hello - running into a slight issue with my VBA where it is copying my formula too high up and not sure how to get an alternative for the results i need. Ask is pretty simply i have 7 columns with a header of data in all. first 3 columns are just data reference of what the data pertains to while the last four are formulas. so looking for the last 4 columns to copy the formula down only if data in the first column. Data starts on A11, headers on A10.

ABCDEFG
Team 1HomeAwayFORMULAFORMULAFORMULAFORMULA
Team 2HomeAway

Range("D11:G11").Select
Selection.AutoFill Destination:=Range("D11:G" & Range("A" & rows.count).End(xlUp).row)
Range(Selection, Selection.End(xlDown)).Select

the VBA is above works in most scenarios but in some i see it overriding my column headers named, D,E,F,G
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Hello - running into a slight issue with my VBA where it is copying my formula too high up and not sure how to get an alternative for the results i need. Ask is pretty simply i have 7 columns with a header of data in all. first 3 columns are just data reference of what the data pertains to while the last four are formulas. so looking for the last 4 columns to copy the formula down only if data in the first column. Data starts on A11, headers on A10.

ABCDEFG
Team 1HomeAwayFORMULAFORMULAFORMULAFORMULA
Team 2HomeAway

Range("D11:G11").Select
Selection.AutoFill Destination:=Range("D11:G" & Range("A" & rows.count).End(xlUp).row)
Range(Selection, Selection.End(xlDown)).Select

the VBA is above works in most scenarios but in some i see it overriding my column headers named, D,E,F,G
ok i think I diagnosed when it happens. if i only have 1 record the VBA falls down.
 
Upvote 0
How about
VBA Code:
Sub ItalianPlatinum()
   Dim UsdRws As Long
   UsdRws = Range("A" & Rows.Count).End(xlUp).Row
   If UsdRws > 11 Then Range("D11:G" & UsdRws).FillDown
End Sub
 
Upvote 0
How about
VBA Code:
Sub ItalianPlatinum()
   Dim UsdRws As Long
   UsdRws = Range("A" & Rows.Count).End(xlUp).Row
   If UsdRws > 11 Then Range("D11:G" & UsdRws).FillDown
End Sub
Per usual worked like a charm! Thank you for the help, always appreciated.
 
Upvote 0
Glad to help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,939
Members
449,094
Latest member
teemeren

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