VBA Relative Referencing

Littlemalky

Board Regular
Joined
Jan 14, 2011
Messages
223
Ok, so here's the situation:

I have one static cell, in this case it's "F48" and I need it to equal the sum that I have at the bottom of another range of data. That range of data always changes in the amount of rows, however the columns are static. In column "J" is the part number, column "K" is the description, column "L" is the quantity, and the only purpose of column "M" is to label the total quantity at the very bottom of the data where everythign is summed.

I can't simply just do a sum formula in the F48 cell because of how everything is arranged and how it changes. Basically, I just need code that looks for the term "Polarized" in column "M", and takes the total quantity that is in the cell directly to the left of it, and copy that quantity into F48.

Any ideas?
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Try

Code:
Sub test()
Dim Found As Range
Set Found = Columns("M").Find(what:="Polarized", LookIn:=xlValues, lookat:=xlWhole)
If Not Found Is Nothing Then Range("F48").Value = Found.Offset(, -1).Value
End Sub
 
Upvote 0

Forum statistics

Threads
1,191,420
Messages
5,986,475
Members
440,031
Latest member
davidvillegasr

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
Top