filling a column in relation to the varying number of rows.

zeekmcphee

New Member
Joined
Feb 27, 2018
Messages
25
Office Version
  1. 2016
Platform
  1. Windows
Hi all
If I place a number or letter at the top of any column,I can drag down to fill the column or I can click the tiny box in the small right hand corner of the top cell and this will fill the column corresponding to the number of rows in the sheet.Is there a way I could use vba to do this programmatically.For example if I wanted to place "Saturday" at the top of the column and fill the rest of the cells in that column with 'Saturday'in relation to the number of rows on the sheet(which will vary).Hope this makes some sort of sense :)
Thankyou
Zeek
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Something can probably be done, but we need more details.
The autofill usually looks at the column to the left to determine how for down to go.
Will that be the case here?
If not, which column can we use to determine where the last row of data resides?

Maybe post an example of your data structure?
 
Upvote 0
Try this: Column you want filled down defaults to active cell column.
You can change this by entering column number in InputBox
Number of times to fill down depends on active sheet UsedRange rows.count
VBA Code:
Sub Fill_Down()
'Modified  6/22/2022  5:53:28 PM  EDT
Application.ScreenUpdating = False
Dim c As Long
c = ActiveCell.Column
Dim Lastrow As Long
Lastrow = ActiveSheet.UsedRange.Rows.Count
Dim ans As Long
ans = InputBox("In what column do you have the value you want to fill down" & _
vbNewLine & "Default Column is active cell column" & vbNewLine & "Fill down depends on UsedRange rows count", "Hello", c)
Cells(1, ans).Resize(Lastrow).Value = Cells(1, ans).Value
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,812
Messages
6,121,696
Members
449,048
Latest member
81jamesacct

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