Excel VBA - Adopt formula to ActiveCell

2Took

Board Regular
Joined
Jun 13, 2022
Messages
203
Office Version
  1. 365
Platform
  1. Windows
Hi,

I intend to trigger from Personal Macro Workbook by a custom button in QAT.

Act upon an ActiveCell.

Active cell is going to be in a Header Row of a spreadsheet. Header Row can be in any row, not necessarily in row one. ActiveCell in any column.

Need VBA to adopt the below formula, such that:
  1. "XX" in it would be replaced by the existing content of the ActiveCell
  2. "A4" in it would be replaced by the Column letter of the ActiveCell and a row number below the ActiveCell
  3. Letter in "A1000000" in it would be replaced by the Column letter of the ActiveCell
*Additional caveat is that Excel does not allow easily to enter a formula into a header, but that's secondary...

Excel Formula:
="XX. Tot: " & COUNTA(A4:A1000000) & " Vis: " & AGGREGATE(3,3,A4:A1000000)
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Excuse me for showing someone how to fish a (very) slightly different way so he/she will be fed for life.

A Merry Christmas and a Happy, Healthy and Prosperous New Year to you and yours.
 
Upvote 0
Excuse me for showing someone how to fish a (very) slightly different way so he/she will be fed for life.
Sorry, didn't mean to upset you.

I looked a little more closely, and just picked up on that subtle difference around when to turn on the Macro Recorder versus when the formula is recorded. I did not notice the the first time around (I have been very distracted lately with a lot going on that really limits my time of this board there days).

Yep, I have used that variation too, specifically when I already have a cell with the formula I need already entered.
Good tip that might save them some time, especially if it is a long complex formula!
 
Upvote 0
No need to apologize Joe. I am old (and experienced I hope) enough to not be bothered by little things. I will answer as I see fit though.

A Merry Christmas, Happy, Healthy and Prosperous New Year to you and yours. I hope you will not be too stressed during these days.
 
Upvote 0

Forum statistics

Threads
1,214,996
Messages
6,122,636
Members
449,092
Latest member
bsb1122

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