VBA Code: Auto Filling Option

mrsriexcel

New Member
Joined
Sep 30, 2015
Messages
15
Hi,
From the below code, the highlighted code is auto filling the cells from G6 to G511 and I am hardcoding the values.

Instead of that is there anyway I can apply Ctl+Shift+Down arrow Function?

or

Is there anyway same formula in G6 can be applied to the no.of cells based on data present in its adjacent column (F)

Range("G6").Select ActiveCell.FormulaR1C1 = "=HPLNK(RC4,RC1,R1C,RC6,R2C,R3C,R4C)"
Selection.AutoFill Destination:=Range("G6:G511")
Range("G6:G511").Select

Regards,
Sri
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Try:
Selection.AutoFill Destination:=Range("G6:G" & Range("F6").End(xlDown).Row)
 
Last edited:
Upvote 0
This auto-fills down from G6 based on the values in column F
Code:
Range("G6:G" & Range("[COLOR=#ff0000][B]F[/B][/COLOR]6").End(xlDown).Row).FormulaR1C1 = "=HPLNK(RC4,RC1,R1C,RC6,R2C,R3C,R4C)"

No need to .Select or use the AutoFill function.
 
Last edited:
Upvote 0
Good point. I should have used column F, not column G in my code. I'll amend that.
And good point about not needing Selects...
 
Last edited:
Upvote 0
Its working good.

Thank You,


I have 2 small questions:

1. from the below code, it is just making the sum of G6:G511.
But instead of that is there anyway we can add all cells from G6 to end (Ctl+Shift+Down Arrow) depends on adjacent column F?

ActiveCell.FormulaR1C1 = "Total"
Range("L3").Select
ActiveCell.FormulaR1C1 = "=SUM(R[3]C[-5]:R[508]C[-5])"

2. If I want to mark a column with Font color (Blue/Green), how can I achieve it? I am using below code but it is showing errors.

ActiveWindow.SmallScroll Down:=-3
Columns("G:G").Select
With Selection.Font
.Color = -65536
.TintAndShade = 0


Regards,
Sri
 
Upvote 0
1.
Range("L3").Formula = "=SUM(G6:G" & Range("F6").End(xlDown).Row & ")"

2.
Columns("G:G").Font.ColorIndex = 14 '14 = Teal or 42 = Aqua
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,105
Messages
6,128,861
Members
449,472
Latest member
ebc9

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