Macro to drag formula from activecell to last column used

taostep1

Board Regular
Joined
May 18, 2016
Messages
65
I am struggling to figure out a macro that will copy my formula on wherever my activecell lands on and drag that formula to the last column of my worksheet.

For example, if my activecell with the formula "1" happens to land on cell b6, I was wondering if there is a VBA code out there that would be smart enough to drag that formula horizontally to the last column (variable) in the worksheet.

This is what I have so far for my code:

Sub test()


Sheets("MTD Gross Margin").Select
Range("B:B").Find("", [B1]).Select
Selection.End(xlDown).Select
ActiveCell.Offset(-1, 0).Select
Selection.Formula = "1"


End Sub
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Last column of data or last column?
Maybe
Code:
ActiveCell.AutoFill Range(ActiveCell, Cells(ActiveCell.Row, Columns.Count))
to fill till the last column
 
Upvote 0

Forum statistics

Threads
1,215,135
Messages
6,123,241
Members
449,093
Latest member
Vincent Khandagale

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