Sub Example()
On Error GoTo ErrHandler
Application.ScreenUpdating = False
Dim src As Workbook
'//Open The Source Excel Workbook In "Read-Only-Mode"
Set src = Workbooks.Open(Cells(103, 103).Value, True, True)
'Set src = Workbooks.Open("E:\Example\Example\Example.xlsx", True, True)
'//Get The Total Rows From The Source Workbook
Dim iTotalRows As Long
iTotalRows = src.Worksheets("Example").Range("B1:B" & Cells(src.Worksheets("Example").Rows.Count, "B").End(xlUp).Row).Rows.Count
MsgBox iTotalRows
Dim iCnt As Long
Dim 행 As Integer
.......
Above is my code.
I apparently specified the sheet's name in below code.
iTotalRows = src.Worksheets("Example").Range("B1:B" & Cells(src.Worksheets("Example").Rows.Count, "B").End(xlUp).Row).Rows.Count
but it returns abnormal result.
What I want to know is "Example" Sheet's rows.
Usually it returns "Example" Sheet's rows well.
because "Example" Sheet is last-opened sheet of the workbook.
When I open another sheet and close and save the workbook, Excel vba code Count that sheet's rows!
I specified apparently sheet's name, but it seems to have no effect.
How Do I solve this problem?
Thank you for your answer in advance.