Insert column and past from input box

Dardus

New Member
Joined
Apr 24, 2017
Messages
15
Thank you for your help. I am not getting this at the moment. I am sure I just need sleep.
Need to insert a column before E, Label it Date4, post the input provided from an inputbox in new E column (except the header):

NameDate1Date2Date3CodeValue1Value2
Bob5/1/201752017123d548h5484/24/2017
Smith5/1/201752017542d879q3125/15/2016
Frank5/1/201752017594f125q6323/2/2016
Sam5/1/201752017668s978q88812/12/2017
Peter5/1/201752017445r879q6883/6/2008
David5/1/201752017684r558q4687/1/2011

<tbody>
</tbody>

To:
NameDate1Date2Date3Date4CodeValue1Value2
Bob5/1/201752017Inputbox value123d548h5484/24/2017
Smith5/1/201752017Inputbox value542d879q3125/15/2016
Frank5/1/201752017Inputbox value594f125q6323/2/2016
Sam5/1/201752017Inputbox value668s978q88812/12/2017
Peter5/1/201752017Inputbox value445r879q6883/6/2008
David5/1/201752017Inputbox value684r558q4687/1/2011

<tbody>
</tbody>
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Code:
Sub insertFill()
Dim dt As String
dt = InputBox("Enter Date", "DATE")
    If dt = "" Then Exit Sub
Columns(5).Insert
Range("E2", Cells(Rows.Count, 4).End(xlUp).Offset(, 1)) = dt
End Sub
 
Upvote 0
Thank you for the quick reply. I should have noted that the amount of rows is undetermined and can fluctuate for each time a new sheet is created. Therefore the " Range("E2", Cells(Rows.Count, 4).End(xlUp).Offset(, 1)) = dt " would not work. Is there a way to make it post the value for the number of rows for that spreadsheet and not the entire column (surpassing where the data cuts off)?
 
Upvote 0
Code:
Sub insertFill()
Dim dt As String
dt = InputBox("Enter Date", "DATE")
    If dt = "" Then Exit Sub
Columns(5).Insert
Range("E2", Cells(Rows.Count, 4).End(xlUp).Offset(, 1)) = dt
End Sub

that's strange, it seemed to work fine on my system. That syntax is for a dynamic range, not a static one. It uses column D to determine the number of rows to fill.
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,582
Members
449,039
Latest member
Arbind kumar

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