vba to filter a column and revise only visible cells

DrandonC

New Member
Joined
Jun 7, 2021
Messages
10
Office Version
  1. 365
Platform
  1. Windows
Hello. I have a list of codes with a column next to it that has units used.
My goal is to find a particular code in the column and THEN multiply it's current value (units) by 50 (replacing the previous value).

It is setup as ColA has codes ColB has Units, ColC - codes, ColD - units, etc.

I have been successful in using a nested 'for' loop but I was wondering if it would be faster to use autofilter and specialcells(xlCellTypeVisible).
But then I'm not sure how to reference the adjacent column to do the calculation. Something to the effect of looping through the visible cells I suppose.

I have something like this so far:

Dim rg As Range
Set rg = Range("B4")

rg.AutoFilter Field:=2, Criteria1:="J1642"

For Each cell In rg.SpecialCells(xlCellTypeVisible)
' calculate the value of the adjacent cell by multiplying it by 50
Next cell

Any help is much appreciated. Thank you.
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

Forum statistics

Threads
1,213,536
Messages
6,114,215
Members
448,554
Latest member
Gleisner2

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