Click here to Skip to main content
15,885,941 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have some set of validation files in excel with formula content. I want to create an macro which by providing necessary folder path it will copy file by file data and paste special it in another file in values with respective file names at another location.

Example:- Suppose If i have formula content excel files as below
Validation 1
validation 2
validation 3
at Location "C:\Bansi\Validation"
my expectation is macro should pick above location path files and past special it into values with names
Validation 1
Validation 2
Validation 2
at location "C:\Bansi\Validation_without formulas"

What I have tried:

I did not tried any thing.
Can anyone help me here
Posted
Updated 2-Dec-19 2:31am
Comments
Richard MacCutchan 2-Dec-19 4:15am    
We cannot help without knowing exactly which part you are having a problem with. But if you are expecting someone here to do the work for you, I am afraid you will be disappointed.

1 solution

Your question is not entirely clear, but I can tell you not to use Paste!

Have a look at this code snippet...
VB
Public Sub test()

    Dim SourceRange As Range, TargetRange As Range
    Set SourceRange = ThisWorkbook.Sheets(1).UsedRange
    
    Set TargetRange = ThisWorkbook.Sheets(2).Range(SourceRange.Address)

    TargetRange.Value = SourceRange.Value
    
End Sub
To see it working, create a workbook with two sheets.

On the first sheet enter some formulae. Run the code - the values calculated by the formulae will be on Sheet 2 … as if you had used Paste, Special, Values. Just much quicker and much more robustly.

To do the file handling bit just use the FileSystem object in VBA - example here VBA List Files in Folder - Automate Excel[^]

If you get stuck after you have written some of your own code then by all means come back with a specific question
 
Share this answer
 
Comments
Maciej Los 2-Dec-19 8:49am    
5ed!
CHill60 2-Dec-19 10:10am    
Thank you! You were the one that originally pointed me in the right direction all that time ago now!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900