mattreingold
05-23-2018, 11:46 AM
Hello, below is a small part of my code. my 'loadArr' is the array I am attempting to obtain the absolute values of - I currently get a mismatch error thrown. Any and all help would be much appreciated!
'//
Sub RunReport()
Set WBT = Workbooks("PeelTestReport.xlsm")
Set WPN = WBT.Worksheets("Sheet2")
Dim xlFile As Variant
Dim numberOfFiles As Integer
numberOfFiles = InputBox("Enter Number of Spreadsheets to Open")
Dim fileNames(100) As String
Dim TotalRows As Integer
Dim Counter As Integer
Dim loadArr As Variant
Dim loadArrUsable As Variant
Counter = 0
ChDir "C:\Users\username\Documents\doc name"
For i = 1 To numberOfFiles
' Showing Excel Dialog
xlFile = Application.GetOpenFilename("All Excel Files (*.csv*)," & _
"*.xls*", 1, "Select Excel File", "Open", False)
' Open selected file
Workbooks.Open xlFile
TotalRows = Rows(Rows.Count).End(xlUp).Row
xlFileName = Right(xlFile, 34)
fileNames(i) = xlFileName
loadArr = Abs(Range("B2:B" & TotalRows))
If Counter = 0 Then
WPN.Range("A1:A" & TotalRows - 1) = loadArr
ElseIf Counter = 1 Then
WPN.Range("B1:B" & TotalRows - 1) = loadArr
...
'//
'//
Sub RunReport()
Set WBT = Workbooks("PeelTestReport.xlsm")
Set WPN = WBT.Worksheets("Sheet2")
Dim xlFile As Variant
Dim numberOfFiles As Integer
numberOfFiles = InputBox("Enter Number of Spreadsheets to Open")
Dim fileNames(100) As String
Dim TotalRows As Integer
Dim Counter As Integer
Dim loadArr As Variant
Dim loadArrUsable As Variant
Counter = 0
ChDir "C:\Users\username\Documents\doc name"
For i = 1 To numberOfFiles
' Showing Excel Dialog
xlFile = Application.GetOpenFilename("All Excel Files (*.csv*)," & _
"*.xls*", 1, "Select Excel File", "Open", False)
' Open selected file
Workbooks.Open xlFile
TotalRows = Rows(Rows.Count).End(xlUp).Row
xlFileName = Right(xlFile, 34)
fileNames(i) = xlFileName
loadArr = Abs(Range("B2:B" & TotalRows))
If Counter = 0 Then
WPN.Range("A1:A" & TotalRows - 1) = loadArr
ElseIf Counter = 1 Then
WPN.Range("B1:B" & TotalRows - 1) = loadArr
...
'//