hercules89
New Member
- Joined
- Jan 24, 2019
- Messages
- 3
Hi,
I am working on a spreadsheet to increase efficiency at work but I have ran into a problem...I have filter column F and then inserted a new column I and input a concatenate formula. I then have tried extending this down to all the other filtered cells and then remove the filter. This seems to work fine when doing manually and recording the macro but then doesn’t work when I try running the macro...the two snippets of code I have are below:
This is the vba code I get when recording the macro but when I run it again it only copies cell I1 into cell I2, rather than copying the formula in I2 down to all filtered cells:
Columns("I:I").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("I1").Select
ActiveCell.FormulaR1C1 = "Unique Ref"
Range("I2").Select
ActiveCell.FormulaR1C1 = "=CONCATENATE(RC[-6],RC[-2])"
Range("I2").Select
Selection.FillDown
This code I have played around with and does appear to extend the formula across all filtered cells but when I remove the filter, it has also applied it all cells, filtered and non-filtered:
Columns("I:I").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("I1").Select
ActiveCell.FormulaR1C1 = "Unique Ref"
Range("I2").Select
ActiveCell.FormulaR1C1 = "=CONCATENATE(RC[-6],RC[-2])"
Range("I2").Select
Selection.AutoFill Range(ActiveCell, ActiveCell.Offset(0, -2).End(xlDown).Offset(0, 2))
Can somebody help me with where I am going wrong here?
Thanks,
Herc
I am working on a spreadsheet to increase efficiency at work but I have ran into a problem...I have filter column F and then inserted a new column I and input a concatenate formula. I then have tried extending this down to all the other filtered cells and then remove the filter. This seems to work fine when doing manually and recording the macro but then doesn’t work when I try running the macro...the two snippets of code I have are below:
This is the vba code I get when recording the macro but when I run it again it only copies cell I1 into cell I2, rather than copying the formula in I2 down to all filtered cells:
Columns("I:I").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("I1").Select
ActiveCell.FormulaR1C1 = "Unique Ref"
Range("I2").Select
ActiveCell.FormulaR1C1 = "=CONCATENATE(RC[-6],RC[-2])"
Range("I2").Select
Selection.FillDown
This code I have played around with and does appear to extend the formula across all filtered cells but when I remove the filter, it has also applied it all cells, filtered and non-filtered:
Columns("I:I").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("I1").Select
ActiveCell.FormulaR1C1 = "Unique Ref"
Range("I2").Select
ActiveCell.FormulaR1C1 = "=CONCATENATE(RC[-6],RC[-2])"
Range("I2").Select
Selection.AutoFill Range(ActiveCell, ActiveCell.Offset(0, -2).End(xlDown).Offset(0, 2))
Can somebody help me with where I am going wrong here?
Thanks,
Herc