I need help creating VBA code

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
not sure how I edit my original post. fixing I wanted.

Workbook 1 is called NFL GRID SCHEDULE


worksheet BUFFALO BILLS


Copy range B1:C17


Open workbook 2 called NFL SCHEDULES


If worksheet hide want it visible worksheet is called SETUP SCHEDULES paste value in column A & B

autofit column B

Only do Buffalo Billls worksheet on NFL grid schedule a button on that worksheet.

Thanks you

Thomas
 
Last edited by a moderator:
Upvote 0
Put the following code on a button in your "NFL GRID SCHEDULE" book.
The "NFL SCHEDULES" book must be in the same folder.


Press the button.
- The macro opens the "NFL SCHEDULES" book
- Copy the range from "NFL GRID SCHEDULE"
- Paste the range into "NFL SCHEDULES"
- Save the "NFL SCHEDULES" book and close it.


Code:
Sub Copy_Schedule()
    Dim w1 As Workbook, w2 As Workbook
    Dim s1 As Worksheet, s2 As Worksheet
    
    Application.ScreenUpdating = False
    Set w1 = ThisWorkbook
    Set s1 = w1.Sheets("BUFFALO BILLS")
    Set w2 = Workbooks.Open(w1.Path & "\" & "NFL SCHEDULES.xlsx")
    Set s2 = w2.Sheets("SETUP SCHEDULES")
    
    s1.Range("B1:C17").Copy
    s2.Range("A" & s2.Rows.Count).End(xlUp)(2).PasteSpecial xlPasteValues
    w2.Save
    w2.Close False
    MsgBox "Copied range"
End Sub
 
Upvote 0
The code did not work on my end. my files on desktop


Thanks you

Thomas


Does it send you an error message?
Did you put the 2 files in the same folder?
File names and sheet names should be as you put them in your description.

Book1, It must contain the macro
Sheet: BUFFALO BILLS

Book2
NFL SCHEDULES.xlsx
Sheet: SETUP SCHEDULES

Ensure that the names of the sheets and book are correct. Try again.
 
Upvote 0

Forum statistics

Threads
1,215,388
Messages
6,124,659
Members
449,178
Latest member
Emilou

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