autofill formula's and paste as value

NatureGreen

New Member
Joined
Mar 12, 2019
Messages
7
Greetings

I'm a vba beginner and trying to make a macro for my monthly Excel tasks.

Every month i get a report. I add a colum but can't do that with vba cause the report has a merged cell in the first row over half of our sheet. So i solved that with adding cells. Got 3 sheets open while working on this one so i need to use ActiveSheet.

Sub McrTest()
ActiveSheet.Range("F5", ActiveSheet.Range("F5").End(xlDown)).Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
ActiveSheet.Range("F5").Select
ActiveCell.Value = "NewColumName"
ActiveSheet.Range("F6").Select
ActiveCell.FormulaR1C1 = "=MID(RC[-1],1,10)"

So far so good. But now i need to autofill the formula down to the last row too and then set the colum to just value.

i have to do this with 2 colums in this sheet cause i also have to add a concatenate formula.

Thanks in advance.
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Hello,

You could test following :

Code:
Sub McrTest()
Dim last As Long
last = ActiveSheet.Cells(Application.Rows.Count, "A").End(xlUp).Row
    Columns("F:F").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
    Range("F5").Value = "NewColumName"
    Range("F6").FormulaR1C1 = "=MID(RC[-1],1,10)"
    Range("F6").Copy Destination:=Range("F7:F" & last)
End Sub

Hope this will help
 
Upvote 0
How about
Code:
Sub Naturegreen()
   Columns(6).Insert
   Range("F5").Value = "New Column"
   With Range("F6", Range("E" & Rows.Count).End(xlUp).Offset(, 1))
      .FormulaR1C1 = "=mid(rc[-1],1,10)"
      .Value = .Value
   End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top