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
 

Some videos you may like

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
55,974
Office Version
  1. 365
Platform
  1. Windows
Try:
Selection.AutoFill Destination:=Range("G6:G" & Range("F6").End(xlDown).Row)
 
Last edited:

AlphaFrog

MrExcel MVP
Joined
Sep 2, 2009
Messages
16,384
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:

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
55,974
Office Version
  1. 365
Platform
  1. Windows
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:

mrsriexcel

New Member
Joined
Sep 30, 2015
Messages
15

ADVERTISEMENT

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
 

AlphaFrog

MrExcel MVP
Joined
Sep 2, 2009
Messages
16,384
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:

Watch MrExcel Video

Forum statistics

Threads
1,123,481
Messages
5,601,918
Members
414,482
Latest member
morkar

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
Top