Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8009209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:22:45+00:00 2026-06-04T18:22:45+00:00

I am trying to write a macro which pastes over the formulae within certain-named

  • 0

I am trying to write a macro which pastes over the formulae within certain-named worksheets with their values, thereby making them exportable. I have successfully got the macro to dupe and rename the worksheets, but can’t get the copy/paste to run on them as I would like.

Currently my macro copies all visible worksheets except one specified (“Dashboard”) and then renames them, replacing ” (2)” with “_VARIABLES”. So far so good. It is then supposed to overwrite formulae in the newly created worksheets with values; this part does not work.

Here is the entire code:

Private Sub testestssss()

Dim ws As Worksheet

'Copy all visible worksheets except "Dashboard" to the end

For Each ws In Sheets

If ws.Name = "Dashboard" Then
Else
If ws.Visible Then ws.Copy after:=Worksheets(Worksheets.Count)
End If

Next

'Rename all "wk * (2)" sheets to "wk *_VARIABLES"

For Each ws In Sheets
If ws.Name Like "* (2)" Then
ws.Name = Replace(ws.Name, " (2)", "_VARIABLES")
End If
Next

'Overwrite all "wk *_VARIABLES" formulae with values

For Each ws In Sheets
If ws.Name Like "*_VARIABLES" Then
Columns("A:B").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
End If
Next

End Sub

So all the above works up until the ‘overwrite all “wk *_VARIABLES” formulae with values’ part. That appears to be ineffective.

Any help will be gratefully appreciated!

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T18:22:46+00:00Added an answer on June 4, 2026 at 6:22 pm

    You keep selecting the column of the active sheet. This should do what you expect:

    For Each ws In Sheets
        If ws.Name Like "*_VARIABLES" Then
            ws.Select
            Columns("A:B").Select
            Selection.Copy
            Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
                                        :=False, Transpose:=False
        End If
    Next
    

    Alternatively, you can simply write this (no need to select and it runs a bit faster without them):

    For Each ws In Sheets
        If ws.Name Like "*_VARIABLES" Then
            ws.Columns("A:B").Copy
            ws.Columns("A:B").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
                                           SkipBlanks:=False, Transpose:=False
        End If
    Next
    

    And finally to save a few keystrokes:

    For Each ws In Sheets
        If ws.Name Like "*_VARIABLES" Then
            With ws.Columns("A:B")
                .Copy
                .PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
                              SkipBlanks:=False, Transpose:=False
            End With
        End If
    Next
    

    And don’t forget to add the following statement after the copy/paste section:

    Application.CutCopyMode = False
    

    to keep things clean.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a Word macro which inserts data from the Current User
I am trying to write a macro in Excel which will allow me to
I am trying to write a macro in VB for an Excel spreadsheet which
I am trying to write a macro for Building my application, kicking off an
I'm trying to write a macro to make a specific usage of callbacks in
I'm trying to write a macro that toggles between release/debug solution configurations in Visual
I'm trying to write a macro to delete all rows that have True in
I'm trying to write a Lisp macro that writes a bunch of macros, but
I am trying to write a simple macro to display a pop-up (vbOKOnly) if
I'm trying to write a very basic macro in VB for Microsoft Word, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.