azizrasul
Well-known Member
- Joined
- Jul 7, 2003
- Messages
- 1,304
- Office Version
- 365
- 2019
- 2016
- Platform
- Windows
I know this is an easy question and I hang my head in shame but I just can't get the answer.
I want to return to the first worksheet (Cover) in the following code.
Thanks in advance.
I want to return to the first worksheet (Cover) in the following code.
Code:
Set objExcelApp = CreateObject("Excel.Application")
Set objWorkBook = objExcelApp.Workbooks.Open(strFilePathAMCorpQueries)
objExcelApp.Visible = True
For Each objWorkSheet In objWorkBook.Worksheets
If objWorkSheet.Name = "Summary" Then
objWorkSheet.Select
objWorkSheet.Range("K14").Select
objExcelApp.ActiveCell.FormulaR1C1 = [Forms]![Form1]![txtQuery_Date]
objWorkSheet.Range("A1").Select
objWorkSheet("Cover").Select 'Need this line to work
End If
Next objWorkSheet
With objExcelApp
.DisplayAlerts = False
.ActiveWorkbook.SaveAs strFilePathAMCorpQueries
.DisplayAlerts = True
.Quit
End With
Set objWorkBook = Nothing
Thanks in advance.