Fill Formula Down Column

rachel06

Board Regular
Joined
Feb 3, 2016
Messages
180
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have a macro that cuts down a spreadsheet that has an absurd number of columns based on an hlookup. Basically, the user decides what columns they want to keep (by pasting the headers into a sheet) and the macro deletes the rest.

Anyway, in the next empty column, I need to enter the below, then copy the formula down the entire column. Since this column is going to be different based on what fields are kept by the user, I cannot specify a specific column to fill down.

What can I add to this so that the formula will fill down the entire column? I've tried using something with lastrow referencing column A but nothing is working for me.

Any help is appreciated :)

Code:
   Sheets("1537").Range("A1").End(xlToRight).Offset(0, 1).Formula = "Run ID"
   Sheets("1537").Range("A1").End(xlToRight).Offset(1, 0) = "=CHOOSECOLS(TEXTSPLIT(RC[-1],""_""),2)"
 
Or use a With statement
VBA Code:
    With Sheets("1537")
        .Range(.Cells(2, lc + 1), .Cells(lr, lc + 1)).FormulaR1C1 = "=CHOOSECOLS(TEXTSPLIT(RC[-1],""_""),2)"
    End With
 
Upvote 0

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