Dynamically Select Cells For Use in a VBA Function

Dynamically Select Cells For Use in a VBA Function

I've written the function below that I would like to use dynamically in my excel sheet where the function would assess the value of the variable selected in the formula and based on that value, perform a simple calculation referencing values in cells in different columns but in the same row.

I've written the function below that I would like to use dynamically in my excel sheet where the function would assess the value of the variable selected in the formula and based on that value, perform a simple calculation referencing values in cells in different columns but in the same row.

I know that the code below works, but how can I rewrite the ranges so that my function can be used dynamically for each row of the same column?

Function AddedValue(TabSize As Integer)

Select Case TabSize

Case 2
    AddedValue = Range("K3") * (Range("N3") * (Range("H3") * 0.001))

Case 4
    AddedValue = Range("K3") * (Range("O3") * (Range("H3") * 0.001))

Case 6
    AddedValue = Range("K3") * (Range("P3") * (Range("H3") * 0.001))

Case 8
    AddedValue = Range("K3") * (Range("Q3") * (Range("H3") * 0.001))

Case 10
    AddedValue = Range("K3") * (Range("R3") * (Range("H3") * 0.001))

End Select End Function


Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

To VBA and beyond - building a RESTful backend using plain Microsoft Excel macros

When my coworkers and I discussed backend technologies for an upcoming project, someone jokingly mentioned Excel as people widely misused it as a terrible database replacement. Although we settled for .NET, the idea of using Excel as a backend fascinated me. Since I just recently finished my bachelor's thesis and had some spare time, I thought I'd give it a shot and see how far I'd get.

Excel VBA – Material Color Palette

![VBAMaterial-Color-Palette-BG](https://i.ibb.co/DwbX8NL/VBAMaterial-Color-Palette-BG.png "VBAMaterial-Color-Palette-BG") Hello there, this article is about how to get Material Color Palette [https://material.io/guidelines/style/color.html#] into...

How to automatically insert a copied row after a specific value in a cell with VBA

I have a table that contains a set of bundles that have to be broken down into their components. For this I'm looking for VBA instructions that will copy any row that contains the tag "-edubnd" at the end of the 'sku' cell (please see table bellow for example) twice underneath itself.