The below code works fine for generic applications.
What if I wanted to input a file on the desktop to a specific sheet named "RAW SCORES"
This seems to be the line in question along with some DIM variable???: targetSheet.Range("B2:B31").Value = sourceSheet.Range("B2:B31").Value
This seems to be simple, but alludes novices like myself
Thanks for any help!
======================
' Get customer workbook
Dim customerBook As Workbook
Dim filter As String
Dim caption As String
Dim customerFilename As String
Dim customerWorkbook As Workbook
Dim targetWorkbook As Workbook
' make weak assumption that active workbook is the target
Set targetWorkbook = Application.ActiveWorkbook
' get the customer workbook
filter = "Text files (*.csv),*.csv"
caption = "Please Select an input file "
customerFilename = Application.GetOpenFilename(filter, , caption)
Set customerWorkbook = Application.Workbooks.Open(customerFilename)
' assume range is B2 - B31 in sheet1
' copy data from customer to target workbook
Dim targetSheet As Worksheet
Set targetSheet = targetWorkbook.Worksheets(1)
Dim sourceSheet As Worksheet
Set sourceSheet = customerWorkbook.Worksheets(1)
targetSheet.Range("B2:B31").Value = sourceSheet.Range("B2:B31").Value
' Close customer workbook
customerWorkbook.Close
What if I wanted to input a file on the desktop to a specific sheet named "RAW SCORES"
This seems to be the line in question along with some DIM variable???: targetSheet.Range("B2:B31").Value = sourceSheet.Range("B2:B31").Value
This seems to be simple, but alludes novices like myself
Thanks for any help!
======================
' Get customer workbook
Dim customerBook As Workbook
Dim filter As String
Dim caption As String
Dim customerFilename As String
Dim customerWorkbook As Workbook
Dim targetWorkbook As Workbook
' make weak assumption that active workbook is the target
Set targetWorkbook = Application.ActiveWorkbook
' get the customer workbook
filter = "Text files (*.csv),*.csv"
caption = "Please Select an input file "
customerFilename = Application.GetOpenFilename(filter, , caption)
Set customerWorkbook = Application.Workbooks.Open(customerFilename)
' assume range is B2 - B31 in sheet1
' copy data from customer to target workbook
Dim targetSheet As Worksheet
Set targetSheet = targetWorkbook.Worksheets(1)
Dim sourceSheet As Worksheet
Set sourceSheet = customerWorkbook.Worksheets(1)
targetSheet.Range("B2:B31").Value = sourceSheet.Range("B2:B31").Value
' Close customer workbook
customerWorkbook.Close