select cell at open

  • Thread starter Thread starter Prema
  • Start date Start date
P

Prema

I open workbook SRP vis vb code in workbook weekly process. I would like cell
D8 to be selected when opened. I have a button in cell J17 of weekly process
work book which I click to open SRP workbook. It opens SRP file but cell J17
is selected. What can I do to make it select D8 of SRP file? Any help will be
appreciated.

My Vb code behind the button is

' Open SRP macro file and close weekly files prep file.
Range("D8").Select
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Workbooks.Open Filename:= _
"\\gbrcrotpc0ms015\pccommon\SALES TEAM\REPORTS Library\CL - Customer
Sales-Out & Stock\z_Files-for-Investigator\5 Dataprep\SRP-update-macro.xls"
Range("D8").Select
Windows("Weekly-files-prep.xls").Activate
Range("D8").Select
ActiveWorkbook.Close
 
Before you open SRP, set a variable:

Set wbx=ActiveWorkbook

Then after the open, replace:

Windows("Weekly-files-prep.xls").Activate
Range("D8").Select
ActiveWorkbook.Close

with:

wbx.Close


Basically, by remembering the prep window, we can avoid going back to it!
 
Hi

This did not work either. When weekly file is closed it seem to remember the
cursor position. My button spans across I16 to K19 and depending on which
part of the button and click related cell is selected in SRP file after
weekly file is closed.
 
Hello
If your button was created from the controls tool bar, then try and set the
button's TakeFocusOnClik property to False.
HTH
Cordially
Pascal
 
Back
Top