Hello VBA Forums.
My name is Zhi. I am new to this forum~ I have some VBA basic skills but I have not used it for a while and trying to get back into using it. Recently, I am trying to analyse a bunch of data which makes it extremely tedious to do it manually. I have this set of data which contains two columns.
I am interested in finding out the area below it using a Macro so I can load a .CSV file and spit out a value with the ability base on a very simple mathematics formula. My question is, how can make such a VBA run a macro when I hit "1. Run Macro > 2. Open Import Data Dialog > 3. Select the .CSV File > 4. Run Macro"?
I would like some help with Step #2? I highlighted the part which I want to adjust. But I do not know what to press to make it open a "Window File Selection" box so I can choose the .CSV file. I want it to be able to computer everything as soon as I select that CSV file. Thank you in advance.
My current code looks like this:
Sub Macro1()
'
' Macro1 Macro
'
'
Range("A1").Select
ActiveCell.FormulaR1C1 = "Volrage (V)"
Range("B1").Select
ActiveCell.FormulaR1C1 = "Current (I)"
Range("C1").Select
ActiveCell.FormulaR1C1 = "Current (mA)"
Range("A2").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Users\z3336083\Dropbox\z3336083\IVIUM CV Measurement\2017 05 11\CV SHE 1V SHE s22-2 W Carbon C\150 mVs\24861705CVcycle11A25301.csv" _
, Destination:=Range("$A$2"))
.Name = "24861705CVcycle11A25301"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 850
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
Range("C2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
Range("C2").Select
ActiveCell.FormulaR1C1 = "=RC[-1]*1000"
Range("C2").Select
Selection.AutoFill Destination:=Range("C2:C1201")
Range("C2:C1201").Select
Range("D2").Select
End Sub
[/SIZE]
Bookmarks