Good Afternoon!
I'm currently working on piecing together a macro that will allow me to pull data from 3 specific ranges of cells in a user-selected file, and copy-paste it into the open excel file. The issue I'm currently battling is a Run Time Error 438: Object doesn't support this property or method from the third line in the third chunk of code, below:
Previously, it was telling me that I was getting an error with global variables, but I seem to have moved past that, at least for now.
Also, while you're looking at this...I also need to figure out how to get the code to find the sheet name in the wbTarget workbook that I'm pulling from. It is different for each of the files, and I can't figure out how to select and copy the data I want without knowing the sheet name beforehand.
I apologize if this is not very straightforward. I haven't done much with VBA, and am piecing this all together based off of lots of googling!
I'm currently working on piecing together a macro that will allow me to pull data from 3 specific ranges of cells in a user-selected file, and copy-paste it into the open excel file. The issue I'm currently battling is a Run Time Error 438: Object doesn't support this property or method from the third line in the third chunk of code, below:
Code:
Sub ReportData()
Dim wbTarget As Workbook
Dim wbThis As Workbook
Dim rTime, rVisc, rTemp As Range
'Choose & Open Data File
Dim FileName As String
FileName = Application.GetOpenFilename()
Set wbTarget = Application.Workbooks.Open(FileName)
Set wbThis = ThisWorkbook
wbThis.Activate
Set rDest = Application.InputBox(Prompt:="Please select the Cell to paste to", Title:="Paste to", Type:=8)
Set rVisc = wbThis.Sheets("5550 Data").rDest.Range(rDest).Offset(0, 1).Value
Set rTemp = wbThis.Sheets("5550 Data").rDest.Range(rDest).Ofset(0, 1).Value
'Copy & Paste Time Data
On Error GoTo 0
wbTarget.Activate
Application.CutCopyMode = False
wbTarget.Sheets("Gustafson Test 1").Range("A85:A2500").Select
wbTarget.Sheets("Gustafson Test 1").Range("A85:A2500").Copy
wbThis.Activate
rDest.PasteSpecial (xlPasteValues)
Application.CutCopyMode = False
'Copy & Paste Visc Data
wbTarget.Activate
wbTarget.Sheets("Gustafson Test 1").Range("H85:H2500").Select
wbTarget.Sheets("Gustafson Test 1").Range("H85:H2500").Copy
wbThis.Activate
rVisc.PasteSpecial (xlPasteValues)
Application.CutCopyMode = False
'Copy & Paste Temp Data
wbTarget.Activate
wbTarget.Sheets("Gustafson Test 1").Range("B85:B2500").Select
wbTarget.Sheets("Gustafson Test 1").Range("B85:B2500").Copy
wbThis.Activate
rTemp.PasteSpecial (xlPasteValues)
Application.CutCopyMode = False
'Close Data File
wbTarget.Close False
End Sub
Previously, it was telling me that I was getting an error with global variables, but I seem to have moved past that, at least for now.
Also, while you're looking at this...I also need to figure out how to get the code to find the sheet name in the wbTarget workbook that I'm pulling from. It is different for each of the files, and I can't figure out how to select and copy the data I want without knowing the sheet name beforehand.
I apologize if this is not very straightforward. I haven't done much with VBA, and am piecing this all together based off of lots of googling!