简体   繁体   中英

Copying Block of Formulas to All Sheets Excel VBA

I have a workbook with many (variable total number) sheets which all have identical column headings and variable number of rows. On the master sheet ("Sheet1") there is a large block of formulas that I need to copy along with formatting to all other sheets. The sheets already have unique titles so it won't work to base it on sheet numbers.

I know it's easier to hardcode the formulas but that's a major task for another day (it's very, very many formulas).

I basically have to copy and paste the formula block from a completely separate workbook into "Sheet1", then copy it from that. Here's what I have so far:

Windows("Step Formula Base.xlsx").Activate
Columns("AK:BP").Select
Application.CutCopyMode = False
Selection.Copy
Windows("NA - Sourcing - HR-IT-SLS Candidate Data %28All Candidates%29.xlsx"). _
    Activate
 Range("AK1").Select
 ActiveSheet.Paste
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Sheet1")
Sheets.FillAcrossSheets_
    ws.Range ("AK:BP")

I'm not quite getting the FillAcrossSheets--thought it would be an easy fix but it breaks on that line. Any thoughts or help?

Thanks!

Here's the working code:

Windows("Step Formula Base.xlsx").Activate
Columns("AK:BP").Select
Application.CutCopyMode = False
Selection.Copy
Windows("NA - Sourcing - HR-IT-SLS Candidate Data %28All Candidates%29.xlsx"). _
    Activate
 Sheets.Select
 Range("AK1").Select
 ActiveSheet.Paste

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM