please help

tweetytoon

New Member
Joined
Jan 21, 2021
Messages
2
Office Version
  1. 365
below code is pasting formulas and i want to past values

VBA Code:
Sub Consolidate_Data()


Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Consolidated_Data")

Dim logs As Worksheet
Set logs = ThisWorkbook.Sheets("logs")

Dim i As Integer
Dim arr
Dim n, x As Long

Dim wb As Workbook
Dim dsh As Worksheet
Dim str As String



arr = Application.GetOpenFilename(MultiSelect:=True)

For i = LBound(arr) To UBound(arr)
    n = sh.Range("A" & Application.Rows.Count).End(xlUp).Row + 1 '''last row of consolidated_data sheet
    x = logs.Range("A" & Application.Rows.Count).End(xlUp).Row + 1 '''last row of logs sheet
   
    Set wb = Workbooks.Open(arr(i))
    Set dsh = wb.Sheets(1)
    dsh.UsedRange.Copy sh.Range("A" & n)
   
    '''''''update logs
    logs.Range("A" & x).Value = wb.Name
    logs.Range("B" & x).Value = Application.WorksheetFunction.CountA(dsh.Range("A:A")) - 1
   
   
    wb.Close False ''''''''' close worksheets
       
Next i

'''''data formatting in consolidated_Data sheet tab

sh.Range("1:1").Delete
sh.UsedRange.AutoFilter 1, "Date"
sh.Range("A2:A" & Application.Rows.Count).SpecialCells(xlCellTypeVisible).EntireRow.Delete
sh.AutoFilterMode = False



''''''''' Data formatting

With sh.UsedRange
    .HorizontalAlignment = xlCenter
    .VerticalAlignment = xlJustify
    .EntireColumn.ColumnWidth = 15
    .EntireRow.RowHeight = 15
    .Font.Size = 10
    .Font.Name = "Calibri"
    .Borders.LineStyle = xlContinuous
    .Borders.Weight = xlHairline
End With

With sh.Range("A1:I1")
    .Font.Bold = True
    .Interior.Color = vbBlack
End With



End Sub
 
Last edited by a moderator:

Some videos you may like

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
55,529
Office Version
  1. 365
Platform
  1. Windows
Hi & welcome to MrExcel.
Change this line
VBA Code:
dsh.UsedRange.Copy sh.Range("A" & n)
to
VBA Code:
dsh.UsedRange.Copy 
sh.Range("A" & n).PasteSpecial xlPasteValues
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
55,529
Office Version
  1. 365
Platform
  1. Windows
You're welcome & thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,127,554
Messages
5,625,474
Members
416,109
Latest member
TripleA00123

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
Top