VBA Copy Paste a Range in Next Available Column Then Add a Single Day to One of the Newly Pasted Cells Repeatedly

0 votes

I'm attempting to make a button with an attached macro that will copy a range of data and formulas, put them in the following column, and then add one day to a single cell. The issue I'm having is that I want to repeat the process, adding one date from each newly added cell to the previously pasted one. The concept is that when I click the button, the pasted block adds one day to the next specified cell after pasting the original range into that cell. After adding data to that new pasted block, I click the button again to receive a new pasted block with the next specific cell added to it.

So far I have this:

Sub PasteToNextEmptyColumn()

    Application.ScreenUpdating = False
        
    Range("A4:C14").Copy
    ActiveSheet.Cells(4, Columns.Count).End(xlToLeft).Offset(0, 1).PasteSpecial xlPasteColumnWidths
    ActiveSheet.Cells(4, Columns.Count).End(xlToLeft).Offset(0, 1).PasteSpecial xlPasteAll

    Range("E9").Value = DateAdd("d", 1, (Range("E9")))


    Application.CutCopyMode = False
    Application.ScreenUpdating = True
    
End Sub
Feb 20, 2023 in Others by narikkadan
• 63,720 points
696 views

1 answer to this question.

0 votes

With a date you can treat it like a value and just put:

  • Range("E9") = Range("E9") + 1 ' this will input the date in the same cell E9

Maybe ensure the date is in DD/MM/YYYY or another recognized format.

I hope this helps you.

answered Feb 20, 2023 by Kithuzzz
• 38,020 points

Related Questions In Others

0 votes
1 answer

VBA Loop to select then copy a range of cells based on value in column B

Try this: Sub Macro2() Dim ...READ MORE

answered Mar 23, 2023 in Others by narikkadan
• 63,720 points
2,182 views
0 votes
1 answer

How can I use a command button in excel to set the value of multiple cells in one click?

Try this: Private Scan As Integer Private Sub CommandButton1_Click() ...READ MORE

answered Oct 24, 2022 in Others by narikkadan
• 63,720 points
734 views
0 votes
1 answer

Sum the total of a column in excel and paste the sum to a different workbook

Get Column Sum From Closed Workbook Option Explicit Sub ...READ MORE

answered Jan 26, 2023 in Others by narikkadan
• 63,720 points
545 views
0 votes
1 answer

How do I copy a specific range of cells after I use AutoFilter in VBA?

Set the range of filtered data Set Rng ...READ MORE

answered Feb 2, 2023 in Others by narikkadan
• 63,720 points
772 views
0 votes
1 answer

Retrieve epay.info Balance with VBA and Excel

This code should log you in, provided ...READ MORE

answered Sep 5, 2018 in Blockchain by digger
• 26,740 points
1,096 views
0 votes
1 answer

How to load file to Excel Power query from SFTP site

Currently, I don't think there is a ...READ MORE

answered Dec 3, 2018 in Power BI by Upasana
• 8,620 points
3,512 views
0 votes
1 answer

Using VBA Excel to create a gramatically correct list

The Excel AND function is a logical ...READ MORE

answered Feb 9, 2022 in Others by gaurav
• 23,260 points
820 views
0 votes
2 answers

How to copy a formula horizontally within a table using Excel VBA?

Hi so basically, create an adjacent column ...READ MORE

answered Feb 16, 2022 in Others by Edureka
• 13,690 points
982 views
0 votes
1 answer

What VBA code would I use to concatenate cell A2 & B2 in cell C2 and then have it Autofill down the column?

Solution Find the last row. Write a formula to ...READ MORE

answered Feb 14, 2023 in Others by Kithuzzz
• 38,020 points
887 views
0 votes
1 answer

Conditional Formatting not applying to all the cells in a given range

Use the following instead as the Formula: =$P5=75% I ...READ MORE

answered Apr 7, 2023 in Others by Kithuzzz
• 38,020 points
554 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP