Paste Values instead of pasting formulas

Brent77

New Member
Joined
Dec 28, 2010
Messages
4
I found a specific formula for collating data from closed worksheets and it works great with one exception, and I'm sure it's a quick fix but I'm new to VBA. I need to formula to paste values instead of pasting the formulas. I'm sure it's a change to one or two lines and I will put the formula below and bold where I think it needs to be changed. Thanks for your time and help; I've been browsing the forum for hours looking for the answer and can't seem to find the right thing! I'm using Excel 2007.

Thanks!

-Brent

Formula:

Option Explicit

Sub CollateReportFromFiles()
'Open all .XLS in specific folder and import data (2007 compatible)
Dim strFileName As String, strPath As String
Dim wbkOld As Workbook, wbkNew As Workbook, ws As Worksheet
Dim NR As Long, LR As Long, i As Long
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.DisplayAlerts = False

Set wbkNew = ThisWorkbook
strPath = "C:\Users\Brent\Desktop\MACRO Test\Files\" 'Your path, don't forget the final \
strFileName = Dir(strPath & "*.xls")
wbkNew.Activate
Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = "Temp"

For Each ws In Worksheets
If ws.Name <> "Temp" Then ws.Delete
Next ws
'Setup
ActiveSheet.Name = "Report"
Range("B1") = "Column 1"
Range("C1") = "Column 2"
Range("B1:C1").Interior.ColorIndex = 6
NR = 2

Do While Len(strFileName) > 0
Set wbkOld = Workbooks.Open(strPath & strFileName)
LR = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To LR
If Not IsEmpty(Cells(i, "B")) And IsEmpty(Cells(i, "C")) Then
Rows(i).Copy wbkNew.Sheets("Report").Range("A" & NR)
NR = NR + 1

End If
Next i
strFileName = Dir
wbkOld.Close False
Loop

Application.ScreenUpdating = True
Application.DisplayAlerts = True
Application.EnableEvents = True
End Sub
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Code:
If Not IsEmpty(Cells(i, "B")) And IsEmpty(Cells(i, "C")) Then
    Rows(i).Copy
    wbkNew.Sheets("Report").Range("A" & NR).PasteSpecial _
        Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    NR = NR + 1
End If
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,323
Members
452,635
Latest member
laura12345

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