select cell at open

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
 
G

Gary''s Student

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!
 
P

Prema

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.
 
P

papou

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top