Frustrated at below code and any code. i have tried over 1000 ways to do one simple thing. to move data from 1 source workbook to thisworkbook.worksheet("summary") workbook. the below code is last ditch effort to get this to work ( over 50 hours trying to get the ( to work.)
now the code very simple
what is wrong?????????????????????????????????????????????????????????????????????????????????????????
now the code very simple
what is wrong?????????????????????????????????????????????????????????????????????????????????????????
VBA Code:
Sub ReadDataFromCloseFile()
On Error GoTo ErrHandler
Dim FileToOpen As Variant
'Application.ScreenUpdating = False
Dim src As Workbook
' OPEN THE SOURCE EXCEL WORKBOOK IN "READ ONLY MODE".
FileToOpen = Application.GetOpenFilename _
(Title:="Browse for your File & Import Range", _
FileFilter:="Excel Files (*.xls*),*xls*")
'If FileToOpen <> False Then '<------------------ disable when enabled it verifs a nill select is not passed.
"end if
Set src = Workbooks.Open(FileToOpen) ' Set src = Workbooks.Open("C:\testbook.xlsm", True, True)
' GET THE TOTAL ROWS FROM THE SOURCE WORKBOOK.
Dim iTotalRows As Integer
iTotalRows = src.Worksheets("sheet1").Range("B1:B" & Cells(Rows.Count, "B").End(xlUp).row).Rows.Count
MsgBox iTotalRows '<------------- verify count of i matches with original files.
' COPY DATA FROM SOURCE TO THE DESTINATION WORKBOOK.
Dim iCnt As Integer ' COUNTER.
For iCnt = 1 To iTotalRows
Worksheets("Sheet1").Range("B" & iCnt).Formula = src.Worksheets("Sheet1").Range("B" & iCnt).Formula
MsgBox src.Worksheets("Sheet1").Range("B" & iCnt).Formula '<-------------------------verify what is to be pasted in destination file (thisworkbook.)
Next iCnt
' CLOSE THE SOURCE FILE.
src.Close False ' FALSE - DON'T SAVE THE SOURCE FILE.
Set src = Nothing
ErrHandler:
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub