Need help to copy a call value in all rows of a dynamic sized table

karl_learnvba

New Member
Joined
Oct 10, 2019
Messages
12
Office Version
  1. 365
Platform
  1. Windows
Hello, I started learning VBA yesterday,.. please bear with me if this is v basic,....

I have a set of data in a worksheet that will vary in size.

i would like to copy the value in cell P2 (10.10.2019) down to the bottom of the column,.. which is currently 4000 rows long.

Column P
Row NumberExp Close DateReport runDate
1December 31, 202010.10.2019
2February 28, 2020
3September 30, 2020
4December 21, 2019
5October 31, 2019
6November 30, 2019
7January 31, 2020
8March 31, 2020
9December 31, 2020
10March 31, 2020
July 31, 2020
December 15, 2019
June 26, 2020
June 01, 2020
September 30, 2020
March 31, 2020
June 30, 2020
LastrowDecember 02, 2019

<tbody>
</tbody>


Thank you all in advance
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Not sure which is the layout of your data.
You need a macro, for example:
Code:
Sub CopyDown()
Dim CopyWhat As String, CloseCol As String, LastClose As Long
'
CopyWhat = "P2"         '<<< Cell to copy down
CloseCol = "M"          '<<< The column "Exp Close Date"
'
LastClose = Cells(Rows.Count, CloseCol).End(xlUp).Row
Range(CopyWhat).Copy Range(CopyWhat).Offset(1, 0).Resize(LastClose - Range(CopyWhat).Row + 1, 1)
End Sub
You have to modify the lines marked "<<<" according the comment
The code has to be inserted in a Standard Module of your vba; if you need furher instruction don't hesitate to ask

Bye
 
Upvote 0
No code required.

Select P3 and press Ctrl+D to copy the value there from P2.

Select P2:P3, then double click on the fill handle, that small dark square at the bottom right corner of the box that highlights the selection. This will fill down as far as you have data in column O.
 
Upvote 0
[...]
Select P3 and press Ctrl+D to copy the value there from P2.

@John: my Excel is not in English, and shortcut Contr+D is used for something else; so I was not able to test how your solution works in case that the driving column is not the one at the left of the target one.

@Karl: Another option without macro is transforming the table in an "Excel Table":
-select leftmost header; Contr-Shift-DownArrow to extend to the end; extend to the right
-Menu /Insert /Table; select "With header"; confirm with Ok

Now if you write in P2 the value in the form of a formula, eg =DATE(2019,10,11), then it will propagate up to the end of the table.

Bye
 
Upvote 0
Ctrl+D is D for "Down", maybe your localization has a similarly familiar keystroke to try.

Anyway, if Ctrl+D doesn't work, copy P2 and paste it into P3, then select P2:P3 and double click the magical fill handle.
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,821
Members
449,049
Latest member
cybersurfer5000

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