Reference VBA action vs. a cell in a formula?

EssKayKay

Active Member
Joined
Jan 5, 2003
Messages
413
Office Version
  1. 2007
Platform
  1. Windows
Hello,
This is similar to a previous post I had.
VBA to populate a textbox with a range sum

Again, I’m looking for a way to eliminate a cell reference only this time it is in a formula. This is a snipit of what I am doing. There is much more going on but I think if I can get this to work I’ll be going in the right direction.

Here’s what’s working:
VBA Code:
If Range("T33") > 0 Then
   Range("T24") = Range("T32").End(xlDown).Offset(1, -2).Value
Else
   Range("T24") = Range("R33")
End If

There is another range of cells containing the following formula where the column remains the same but the row changes as the formula is copied down the range. As noted, the reference to cell $T$24 remains constant.

=IF(P33="",IF(YEAR(C33)=$T$24,Q33,0),0)

Maybe this is not possible but what I was hoping for was to eliminate the need to populate cell T24 and replace it with some code. I tried something like this (which I know is wrong).
=IF(P33="",IF(YEAR(C33)= (Range("T32").End(xlDown).Offset(1, -2).Value) ,Q33,0),0)

If this becomes too involved or complicated, I’ll just leave it as is.

Thanks for viewing,
Steve K.
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
You can't just put VBA statements in a formula. There isn't anywhere near enough context in your post for me to suggest the best alternative, but I'm not really sure why you can't just put a formula in F24 to get the value you need directly?
 
Upvote 0
You can't just put VBA statements in a formula. There isn't anywhere near enough context in your post for me to suggest the best alternative, but I'm not really sure why you can't just put a formula in F24 to get the value you need directly?
Thank you Rory for responding so quickly. I think I'm going to just leave it as is for now. I do appreciate your time and comment.

Again, thanks. . .
Steve
 
Upvote 0

Forum statistics

Threads
1,224,712
Messages
6,180,500
Members
452,987
Latest member
johnsonlily7890

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