# VBA - Entering formula



## superfb (Dec 22, 2022)

Hi,

The below code i have had helped with in a previous thread. However, i am trying to enter a formula in the last row of data in Col C but it isnt entering it.

Additionally when this data has been enter i would like it to be copied and pasted values and the subsequent column D - 0 the values to be cleared.

Many thanks



```
Sub Macro4()
'
With Range("C" & Rows.Count).End(xlUp)
      .Offset(, -2).Resize(, 14).Copy
      .Offset(, -2).Insert xlDown
   End With
   
 With Range("C" & Rows.Count).End(xlUp).Select
 
 FormulaR1C1 = "=IF(R[-1]C=""Mar"",""Jun"",IF(R[-1]C=""Jun"",""Sep"",IF(R[-1]C=""Sep"",""Dec"",IF(R[-1]C=""Dec"",""Mar""))))"
  End With
 
 
End Sub
```


----------



## RoryA (Dec 22, 2022)

It should be:


```
With Range("C" & Rows.Count).End(xlUp)
 
.FormulaR1C1 = "=IF(R[-1]C=""Mar"",""Jun"",IF(R[-1]C=""Jun"",""Sep"",IF(R[-1]C=""Sep"",""Dec"",IF(R[-1]C=""Dec"",""Mar""))))"
.Value = .Value
End With
```

I don't know what this means:



> and the subsequent column D - 0 the values to be cleared


----------



## superfb (Dec 22, 2022)

RoryA said:


> It should be:
> 
> 
> ```
> ...


Thank you!

"and the subsequent column D - 0 the values to be cleared"

The month is in column C, i basically wanted another step to clear out the contents/data in those columns after copying and pasting the last row


----------



## RoryA (Dec 22, 2022)

superfb said:


> The month is in column C, i basically wanted another step to clear out the contents/data in those columns



In which columns?


----------



## superfb (Dec 22, 2022)

RoryA said:


> In which columns?


Column D,E,F,G,H,I,J,K,L,O


----------



## RoryA (Dec 22, 2022)

The entire column, or just the same row as the formula went into?


----------



## superfb (Dec 22, 2022)

RoryA said:


> The entire column, or just the same row as the formula went into?


Just the row after it has inputted the formula thanks


----------



## RoryA (Dec 22, 2022)

You can use:


```
With Range("C" & Rows.Count).End(xlUp)
 
.FormulaR1C1 = "=IF(R[-1]C=""Mar"",""Jun"",IF(R[-1]C=""Jun"",""Sep"",IF(R[-1]C=""Sep"",""Dec"",IF(R[-1]C=""Dec"",""Mar""))))"
.Value = .Value
Intersect(.Entirerow, range("D:L,O:O")).Clear
End With
```


----------

