Jump to content

Hi guys, sorry if im not clear about my problem right away but Im new to excel. Im trying to find the average of 2-however many cells in the same row, but they arent always in the same place. I need a way to dynamically adjust the beginning and end of the average. Is there an easy way to tell excel this? I have lnCol as the col i want to start in, Yrs as the number as years are present, and 2 for adjustment, 

 

 

Cells(5, lnCol + Yrs + 2).Formula = "=Average(I5:J5)"

 

Thanks for your help :)

Intel i5-6600K, be quiet! Dark Rock Pro 3, Asus MAXIMUS VIII Gene, 16gb Crucial Ballistix Sport DDR4, 500gb Samsung 850 Evo, 2tb Seagate Barracuda, GTX 1080 EVGA FTW, Thermaltake Core v21, Seasonic M12II 850W

Link to comment
https://linustechtips.com/topic/627184-vba-help/
Share on other sites

Link to post
Share on other sites

You are being too specific without properly defining your context: Years, 2? How are we supposed to know what those magic variables even mean?

 

In any event a generic solution would be to scan (using a loop) for the first cell that is not empty. Then scan for the next empty cell... Under the assumption that the data is contiguous you then have your range.

The single biggest problem in communication is the illusion that it has taken place.

Link to comment
https://linustechtips.com/topic/627184-vba-help/#findComment-8092796
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×