Hello!
I'm a new member of the forum and I'm just learning how to use vba in Excel. However, I've run into a problem. I am using the below vba code to open and read another excel spreadsheet to pull data from that file and insert it into my current workbook. It worked perfectly in Excel 2003.
However, my customer is using Excel 2010, therefore I had to convert the application. The application works, but it actually displays the file that is being opened for a few seconds and then it disappears. I don't want this data file to display at all. How do I prevent this from happening?
Any and all help is greatly appreciated!
This is the code I'm using:
Sub GetInputData()
' Get InputData workbook...
Dim InputDataBook As Workbook
Dim filter As String
Dim caption As String
Dim InputDataFilename As String
Dim InputDataWorkbook As Workbook
Dim targetWorkbook As Workbook
' make weak assumption that active workbook is the target
Set targetWorkbook = Application.ActiveWorkbook
' get the InputData workbook
filter = "Text files (*.xls),*.xls"
caption = "Please Select input file"
InputDataFilename = Application.GetOpenFilename(filter, , caption)
Set InputDataWorkbook = Application.Workbooks.Open(InputDataFilename)
' copy data from InputData file to target workbook
Dim targetSheet As Worksheet
Set targetSheet = targetWorkbook.Worksheets(1)
Dim sourceSheet As Worksheet
Set sourceSheet = customerWorkbook.Worksheets(1)
targetSheet.Range("h11").Value = sourceSheet.Range("F29").Value + sourceSheet.Range("f30").Value
targetSheet.Range("h12").Value = sourceSheet.Range("F31").Value + sourceSheet.Range("f32").Value
targetSheet.Range("h13").Value = sourceSheet.Range("F27").Value + sourceSheet.Range("f28").Value
targetSheet.Range("h14").Value = sourceSheet.Range("F33").Value + sourceSheet.Range("f34").Value
.
.
.
.
etc
End Sub
Bookmarks