Add few variables to a working subroutine VBA

zack8576

Active Member
Joined
Dec 27, 2021
Messages
271
Office Version
  1. 365
Platform
  1. Windows
I have this code that counts the total number of item "EYEBOLTS", adds 1 additional row to the end of the excel to show the qty of the EYEBOLTS and some other information
(see screenshot below)

Now we added "EYEBOLTS 2" and "EYEBOLTS 3" to our excel files, so I will need this code to also count those
Each file will only contain one of the three items, so we will still just be adding one additional row to the files.
for EYEBOLTS 2 the offset(,1).Value will be F09721
for EYEBOLTS 3 the offset(,1).Value will be F09722

any help is greatly appreciated !

VBA Code:
Sub Eyebolts()
    lr2 = lr + 1   
    Set c = ws1.Range("C" & lr2)  
    With c
        .Offset(, -2).Value = .Offset(-1, -2).Value
        .FormulaR1C1 = "=COUNTIF(R2C11:R" & lr & "C11,""EYEBOLTS"")"
        .Value = .Value
        .Offset(, -1).Value = "!"
        .Offset(, 1).Value = "F09720"
        .Offset(, 6).Value = "Purchased"
        .Offset(, 8).Value = "EYEBOLT"
        .EntireRow.Font.Bold = True
    End With
    If ws1.Range("C" & i3).Value Like "*0*" Then
            ws1.Rows(lr2).Delete
        End If
End Sub

1665519510334.png
 

Attachments

  • 1665518834630.png
    1665518834630.png
    38.4 KB · Views: 11
  • 1665518885617.png
    1665518885617.png
    21.5 KB · Views: 10

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Forum statistics

Threads
1,223,894
Messages
6,175,254
Members
452,623
Latest member
Techenthusiast

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