Attempting to use your suggestion of not selecting things. Can get most to work except restoring the original activecell position on target workbook. Attempting to keep screen flashing between workbook and worksheets to a minimum. Below is a demo macro to illustrate my dilemma.
I have two workbooks 1) – Scorecard*, 2) – Projects*. Each workbook has multiple worksheets. The macro should not care what is active at runtime yet move cell pointer to a saved cell address at the end of a series of macros. Everything is hard coded in the demo to keep it simple
The first 1) workbook is a downloaded workbook generated by a mainframe. The second 2) workbook is a log book to pull specific records from first workbook.
Thanks,
D. Buckman
US Army Corps of Engineers, Omaha
Learn from the past, Live in the present, Create the future
I have two workbooks 1) – Scorecard*, 2) – Projects*. Each workbook has multiple worksheets. The macro should not care what is active at runtime yet move cell pointer to a saved cell address at the end of a series of macros. Everything is hard coded in the demo to keep it simple
The first 1) workbook is a downloaded workbook generated by a mainframe. The second 2) workbook is a log book to pull specific records from first workbook.
Code:
Sub dbsel()
‘ all values are hardcoded for testing
‘ opening or target test workbook
Windows("Scorecard-Proj-020212.xlsb").Activate
cSCWorkBook = ActiveWorkbook.Name
cSCWorkSheet = ActiveCell.Worksheet.Name
‘ jump to any different workbook
Windows("Projects-12-v2.xlsb").Activate
‘ when this code runs it will not know
‘ what workbook s active but needs to
‘ move cell pointer to original active cell on target workbook/sheet
With Windows(cSCWorkBook)
With Workbooks(cSCWorkBook).Sheets(cSCWorkSheet)
‘ cell address is hard coded for testing
[b].Range("A1").Select[/b] ‘ fails with “Select method of Range class failed”
End With
End With
End Sub
Thanks,
D. Buckman
US Army Corps of Engineers, Omaha
Learn from the past, Live in the present, Create the future