VBA help, copy contents of cell down column to last row

docsavagedp

New Member
Joined
Mar 7, 2015
Messages
1
Hello,
I have a monthly worksheet I need to add a date column to. Needs to be inserted into middle of sheet (Column E).

New Column
Department NameNameReporting Date# Tickets
HousingSmith<st1:date ls="trans" Month="2" Day="29" Year="2016">2/29/2016</st1:date> 100
HousingJones<st1:date ls="trans" Month="2" Day="29" Year="2016">2/29/2016</st1:date> 102
HousingKelley<st1:date ls="trans" Month="2" Day="29" Year="2016">2/29/2016</st1:date> 116
MaintJones, K<st1:date ls="trans" Month="2" Day="29" Year="2016">2/29/2016</st1:date> 98
<colgroup><col width="84" style="width: 63pt; mso-width-source: userset; mso-width-alt: 3072;"> <col width="68" style="width: 51pt; mso-width-source: userset; mso-width-alt: 2486;"> <col width="81" style="width: 61pt; mso-width-source: userset; mso-width-alt: 2962;"> <col width="68" style="width: 51pt; mso-width-source: userset; mso-width-alt: 2486;"> <tbody> </tbody>

My code is intended to :
1. Insert a new column
2. Enter a date into an InputBox, Then copy date entered to Cell E2
3. Copy cell E2 down to last row of data

Unfortunately my code copies too far or too short.

I am a newbie with VBA and I cant seem to locate the problem in the code. Any help would be a huge lifesaver!

Thanks in advance!

Code:
'Insert Date Column
    Columns("E:E").Select
    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
    Range("E1").Select
    ActiveCell.FormulaR1C1 = "Reporting Date"
    Application.CutCopyMode = False
    
    'Prompt for date
    Range("E2").Select
    myValue = InputBox("Enter Reporting Date")
    Range("E2").Value = myValue
    Application.CutCopyMode = False
    
    'Copy Date to last row
    Range("E2").Select
    Selection.Copy
    Range("E3:E" & endRow).Select
    ActiveSheet.Paste
    Application.CutCopyMode = False
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Code:
    Columns("E:E").Insert Shift:=xlToRight
    Range("E1") = "Reporting Date"
    lRow = Range("C" & Rows.Count).End(xlUp).Row
    Range("E2:E" & lRow).Value = InputBox("Enter Reporting Date")
 
Upvote 0

Forum statistics

Threads
1,215,465
Messages
6,124,973
Members
449,200
Latest member
Jamil ahmed

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