简体   繁体   中英

Excel VBA Adding the Value to the Existing Value instead of Replacing it?

I would like it if when it locates the coordinates, it adds the value in 'M19' to the existing value in the cell instead of replacing. If anyone has a resolution to improving this code I would really appreciate the help. Thank you

Sub AddValue()
 
Dim row As String
Dim c As Single, r As Single
 
With Worksheets("Inventory")
 
    If .Range("M17").Value = "" Then Exit Sub
 
    row = .Range("M17").Value
 
    c = Application.Match(column, .Range("G5:G35"), 0)
    r = Application.Match(row, .Range("B5:B35"), 0)
 
    .Range("B4").Offset(r, c).Value = .Range("M19").Value
 
End With
End Sub

Simply

.Range("B4").Offset(r, c).Value =.Range("B4").Offset(r, c).Value +.Range("M19").Value

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM