wethegoodvibes

New Member
Joined
Aug 29, 2019
Messages
3
Hello

I am working on an excel file with 7 sheets. The main interaction that a user will have with the worksheet is through a user form. The user form as multiple pages and one page is already completely functional. The next page, however, is giving me a lot of problems. The first problem I am working through not being able to paste a collection cells that is on a reference sheet (sheet 7). The collection of cells is a template of sorts with colored cells and a border in certain spots. It is 2 columns x 12 rows. I need to paste that template every time the user hits the “New Day” button on the user form.

So far I understand that the following code may work to go to a new line every time the “New Day” button is pressed. I have defined the template selection as “StartUpTemplate” on sheet 7. My thought is that it will paste that template in the D and E columns every time the “New Day” button is pressed. But it doesn’t know what “StartUpTemplate” is. So how do I store that template into a variable to paste on command?

Private Sub NewDayCommandButton_Click()

Dim NewDay As Range
Dim StartUpData As Worksheet

Set StartUpData = Sheet5
Set NewDay = StartUpData.Range("D65356").End(xlUp).Offset(13, 0)
NewDay.Offset(0, 0).Value = StartUpTemplate

End Sub
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Hi & welcome to MrExcel.
While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.

Can you please supply links to all other sites where you have asked this question.
Thanks
 
Upvote 0
Perhaps something like this? I've assumed the template sheet is called "Template"

Code:
Sub newDay()
    Dim sht As Worksheet, x As Long
    x = 1
    Sheets("Template").Copy After:=Sheets(Sheets.Count)
    On Error Resume Next
    Set sht = Sheets("New Day (" & x & ")")
    While Not sht Is Nothing
        x = x + 1
        Set sht = Nothing
        Set sht = Sheets("New Day (" & x & ")")
    Wend
    On Error GoTo 0
    Sheets(Sheets.Count).Name = "New Day (" & x & ")"
End Sub
 
Upvote 0
Hi & welcome to MrExcel.
While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.

Can you please supply links to all other sites where you have asked this question.
Thanks

https://www.excelforum.com/excel-programming-vba-macros/1288203-string-array.html#post5185605
http://www.vbaexpress.com/forum/showthread.php?65790-String-Array&p=393895&posted=1#post393895
 
Upvote 0
This is what ended up working.

Code:
Private Sub NewDayCommandButton_Click()


Dim StartUpTemPlate As Range, SUTPaste As Range, SUDate As Range


Dim StartUpData As Worksheet


Set StartUpTemPlate = Sheet1.Range("e2:f13")
Set StartUpData = Sheet5
Set SUTPaste = StartUpData.Range("D65356").End(xlUp).Offset(0, 0)


StartUpTemPlate.Copy
SUTPaste.Offset(0, 0).PasteSpecial

End Sub
 
Upvote 0
Glad you got it sorted & thanks for letting us know the solution. :)
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,843
Members
449,051
Latest member
excelquestion515

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