import sum to another file

stams

New Member
Joined
Sep 26, 2020
Messages
2
Platform
  1. Windows
Hello all, trying to import some fixed cells from multiple excel files. 1st and 2nd cells are text and numbers and import fine, but my third cell is a sum (H47:H49) and shows the formula when imported (#REF!) I'd like to show the total of the sum.

very new to this VBA scripting, what shoudl I change to get my sum from "H50" Cell?


Sub CreateList()
Dim iFilesNum As Integer
Dim intCounter As Integer
Dim lCount As Long
Dim recMyFiles() As FoundFileInfo
Dim wbResults As Workbook
Dim wbDest As Workbook
Dim blFilesFound As Boolean

Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.EnableEvents = False

On Error Resume Next
Set wbDest = ThisWorkbook
intCounter = -1
blFilesFound = FindFiles("C:\path_to_files", recMyFiles, iFilesNum, "*.xls*", True)
If blFilesFound Then
intCounter = intCounter + 1
For lCount = 1 To iFilesNum 'Loop through all
intCounter = intCounter + 1
'Open Workbook x and Set a Workbook variable to it
Set wbResults = Workbooks.Open(Filename:=recMyFiles(lCount).sPath & recMyFiles(lCount).sName, UpdateLinks:=0)

wbResults.Sheets(1).Range("I6").Copy Destination:=wbDest.Sheets(1).Range("A" & intCounter)

wbResults.Sheets(1).Range("B12").Copy Destination:=wbDest.Sheets(1).Range("B" & intCounter)

wbResults.Sheets(1).Range("H50").Copy Destination:=wbDest.Sheets(1).Range("C" & intCounter)

wbResults.Close SaveChanges:=False
Next lCount
End If
On Error GoTo 0
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
nevermind got it working, if you ever get the same issue, replace the following line:

wbResults.Sheets(1).Range("H50").Copy Destination:=wbDest.Sheets(1).Range("C" & intCounter)
by
wbResults.Sheets(1).Range("H50").Copy
wbDest.Sheets(1).Range("C" & intCounter).PasteSpecial Paste:=xlPasteValues
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,331
Members
452,636
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