I'm using a macro which I'll post below to add £5.00 onto a value via a button. Is it possible to add an IF statement to this macro to only add £5.00 to the selected cells based on the value of another cell? For example, if I have £0.00 in cell A1 and I want to add £5.00 but only if B1=3. If B1 didn't equal 3 I wouldn't want it to add anything.
Hopefully this makes sense
This is the macro I'm currently using;
Code: Select all
Sub add_5pounds
oDoc = ThisComponent
oView = oDoc.getCurrentController()
oSheet= oView.getActiveSheet()
oSel = oDoc.getCurrentSelection()
oAddr = oSel.getRangeAddress()
nSCol = oAddr.StartColumn
nSRow = oAddr.StartRow
nECol = oAddr.EndColumn
nERow = oAddr.EndRow
for j = nSCol to nECol
for i=nSRow to nERow
oCell = oSheet.getCellByPosition(j,i)
oCell.value = oCell.value + 5.00
next 'i
next 'j
End Sub