Hello everyone,
I am new to VBA and i would appreciate any help as i am pretty confused.
I have imported some csv from a folder to different tabs.
i need to calculate the average of the range A3:A7, then B3:B7 till E3:E7 and report their values on cells K7 to O7 and then do the same starting 4 cells lower i.e. A11 and report to K11 to O11 and loop for the entire workbook.
This is what i've done (found) so far.
Thank you
Sub csvtotabs()
Dim strPath As String
Dim strFile As String
'
strPath = "C:\Users\jlymperopoulos\Desktop\gia macro\ccc\"
strFile = Dir(strPath & "*.csv")
Do While strFile <> ""
With ActiveWorkbook.Worksheets.Add
With .QueryTables.Add(Connection:="TEXT;" & strPath & strFile, _
Destination:=.Range("A1"))
.Parent.Name = Replace(strFile, ".csv", "")
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = True
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End With
strFile = Dir
Loop
Set shtJT = ActiveWorkbook.ActiveSheet
Range("K7").Formula = "=Average(D4:D7)"
Set shtJT = ActiveWorkbook.ActiveSheet
Range("L7").Formula = "=Average(E4:E7)"
Set shtJT = ActiveWorkbook.ActiveSheet
Range("M7").Formula = "=Average(F4:F7)"
Set shtJT = ActiveWorkbook.ActiveSheet
Range("N7").Formula = "=Average(G4:G7)"
Set shtJT = ActiveWorkbook.ActiveSheet
Range("O7").Formula = "=Average(H4:H7)"
End Sub