Using VBA code to search and minus cell value
Closed
Ly2424
-
26 Mar 2018 à 06:09
TrowaD Posts 2921 Registration date Sunday 12 September 2010 Status Contributor Last seen 27 December 2022 - 27 Mar 2018 à 11:34
TrowaD Posts 2921 Registration date Sunday 12 September 2010 Status Contributor Last seen 27 December 2022 - 27 Mar 2018 à 11:34
Related:
- Using VBA code to search and minus cell value
- Vba find - Guide
- Spybot search and destroy - Download - Antivirus
- Yahoo search history - Guide
- Cs 1.6 code - Guide
- Vba case like - Guide
1 response
TrowaD
Posts
2921
Registration date
Sunday 12 September 2010
Status
Contributor
Last seen
27 December 2022
555
27 Mar 2018 à 11:34
27 Mar 2018 à 11:34
Hi Ly2424,
Have a look a the code below. Let the green text help you understand the code:
Best regards,
Trowa
Have a look a the code below. Let the green text help you understand the code:
Sub RunMe()
Dim fCol, fRow As Range
Dim cHeader, rHeader As String
cHeader = Range("K1").Value 'This cell refers to the column header to lookup
rHeader = Range("K2").Value 'This cell refers to the row header to lookup
Set fCol = Rows(1).Find(cHeader) 'Finding the column header
Set fRow = Columns("A").Find(rHeader) 'Finding the row header
Cells(fRow.Row, fCol.Column).Value = Cells(fRow.Row, fCol.Column).Value - 1 'subtracting 1
End Sub
Best regards,
Trowa