I have a column (E
) of items that are filled with codes that resemble the following format: 5301-500-300-000
with an adjacent column (F
) of 'amounts paid' that look like the following: 53.20
My goal is to multiply the appropriate amounts in column F
with the right tax rebates by using a nested if formula in vba. I've managed to do this using excel functions as follows:
a left(E2,4)
formula
& a mid(E2,10,2)
formula followed by a
=IF(OR(F282=1151,F282=1153),IF(OR(G282=131,G282=200,G282=210,G282=300,G282=310,G282=320,G282=800,G282=821,G282=831,G282=841,,G282=700,G282=721),H282*0.5,IF(OR(G282=341,G282=351,G282=400,G282=410,G282=421,G282=431,G282=441,G282=500,G282=511,G282=521,G282=531,G282=600,G282=611,G282=900,G282=700,G282=721),H282*0.3031,0)))
formula
My question is how could I convert this series of excel formulas into a vba format so that I wouldn't have to constantly use the LEFT
& MID
excel functions.
So far, I've tried creating variables for left' &
mid `
Private Sub CommandButton2_Click()
Dim taxcode As Range, location As Range
Set taxcode = Left(Range("E2:E10000"), 4)
Set location = Mid(Range("E2:E10000"), 10, 2)
End Sub
But have already seen problems with my code. Any help would be most appreciated.