# Thread: Convert Formula to Macro

1. ## Convert Formula to Macro

Hi,

I need to convert this formula to Macro which will ease my work, no more need to drag it.
Please some help me to convert this formula into a Macro.

Code:
```Formula in column J
=IF(C2=10,"1010",IF(C2=11,"1111","1414"))

Formula in column K
=RIGHT(CONCATENATE("00000000",D2),8)

Formula in column L
=CONCATENATE(I2,J2,K2)```

2. Do you want the values in J, K & L or do you just want the result in K?

cheers, Paul

3. Originally Posted by Paul T
Do you want the values in J, K & L or do you just want the result in K?

cheers, Paul
Yes first to have the values in J, K and then in L.

4. Personally I'd leave the 3 formulas as they are. Having a macro to add values to 3 cells seems a lot of work for not much gain.
Rather than dragging the formula you can select the cell and then double click on the bottom right cell corner to auto-fill the cells below, assuming you have data in the preceding column.

cheers, Paul

5. Danny,

Paul is probably right but if your situation warrants it, try this:
Code:
```Sub CopyFormulas()
With ActiveSheet
.Range("J2").Formula = "=IF(C2=10," & """1010""" & ",IF(C2=11," & """1111""" & "," & """1414""" & "))"
.Range("K2").Formula = "=RIGHT(CONCATENATE(" & """00000000""" & ",D2),8)"
.Range("L2").Formula = "=CONCATENATE(I2,J2,K2)"
'COMMENT OUT OR REMOVE THE NEXT LINE IF YOU DO NOT WANT TO FILL THE COLUMNS
.Range("J2:L2").AutoFill Destination:=Range("J2:L15"), Type:=xlFillDefault
End With
End Sub```
DANNY2.png

HTH,
Maud

6. ## The Following User Says Thank You to Maudibe For This Useful Post:

danny69 (2015-08-04)

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•