Hi all,

I have some code, shown below, which simply allows me to insert CSV files into excel, and then delete some rows and conduct some calculations.

Sub File1Import()
'
' Load File 1
'
'
Dim Load
Dim strValue As String
Dim strCellNum As String
Dim x As String
' Declare variables
x = 1
y = 1
' Set x and y variables to 1
ChDrive "C:\"
' Set Drive
ChDir "C:\Documents and Settings\ppagano\Desktop\Spring Rate Viewer Development\Spring Rate Data"
' Set Directory
    Load = Application.GetOpenFilename("CSV Files (*.CSV), *.CSV")
' Open File Open Dialogue Box
  Sheets("Sheet2").Activate
' Activate Sheet 2
Columns("A:Z").Select
Selection.Delete Shift:=xlToLeft
' Delete columns A-Z - this deletes any stored data to ensure only one file is loaded into this sheet at a time
    If Load = False Then
    Sheets("Sheet1").Activate
    MsgBox "No file specified.", vbExclamation, "Error"
    Exit Sub
' If file open dialogue box cancelled, active Sheet 1 and display an error message box
    Else
        With ActiveSheet.QueryTables.Add(Connection:= _
        "TEXT;" & Load, Destination:=Range("A:C"))
                  .TextFileCommaDelimiter = True
        .Refresh BackgroundQuery:=False
' If file selected from the dialogue box, open it in Sheet 2, cell A1. Separate the data with a comma
End With
' End with statement
End If
' End if statement
Range("C:I").Delete
Range("1:58").Delete
' Delete columns C-I, and rows 1-58.
    Range("C1") = "Rate"
' Label Column C as Rate
    Range("C4").Select
    ActiveCell.FormulaR1C1 = "=(R[+200]C[-1]-RC[-1])/(R[+200]C[-2]-RC[-2])"
    Selection.AutoFill Destination:=Range("C4:C100004"), Type:=xlFillDefault
' Divide change in force by change in displacement with a 200 data point sample, and conduct this for 100000 rows
Sheets("Sheet1").Activate
' Activate Sheet 1
End Sub
This data is used later to compile a graph, but I require the filename to name each of the data sets for ease of understanding. How do I take the filename from the selected CSV file from the dialogue box, and place it in a cell to be read at a later stage?

Any help would be greatly appreciated.

Thanks.