Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 144
Default Issue with workbook not being selected when form button is clicked

Hi all,

I have an issue where I have a form come up that requires the user to select
a checkbox and then select a "Proceed" button that results in code being
executed and then the form closing. The issue I have is that when the form
is opened, if I then click into another spreadsheet that I have open and then
click on say the "Proceed" button of the form (which applies to the other
spreadsheet), I get an error because the code is applied to the other
spreadsheet (not the one that the form is intended for).

I'm wondering what the best way is to get around this issue. I would just
hardcode in the name of the file for which the code is intended for only that
there are many different people that will use the spreadsheet and they can
save a different name to the file. What I tried to do was put the the
following formulas into the spreadsheet in order to get the name of the
spreadsheet and then use the code below to select the spreadsheet -- the
issue is that for some reason, the spreadsheet formulas sometimes show
"SOLVER" as the file name which is incorrect..then when I double click in the
cell, the correct name of the file shows again.

Spreadsheet formulas:

- cell BA1 formula: =CELL("filename")

- cell BB1 formula:
=IF(ISERROR(LEFT(BA1,SEARCH("]",BA1)-5)),LEFT(BA1,SEARCH(".",BA1)-1),LEFT(BA1,SEARCH("]",BA1)-5))

- cell BC1 formula:
=IF(ISERROR(RIGHT(BB1,LEN(BB1)-SEARCH("[",BB1))),BB1,RIGHT(BB1,LEN(BB1)-SEARCH("[",BB1)))

Code executed when "Proceed" button of form clicked ("strworkbname" is the
value within cell BC1):

Windows(strworkbname).Activate

--
Robert
  #2   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Issue with workbook not being selected when form button is clicked

if you want the code to run on the same workbook in which the form is
located, try using ThisWorkBook.Activate


"robs3131" wrote:

Hi all,

I have an issue where I have a form come up that requires the user to select
a checkbox and then select a "Proceed" button that results in code being
executed and then the form closing. The issue I have is that when the form
is opened, if I then click into another spreadsheet that I have open and then
click on say the "Proceed" button of the form (which applies to the other
spreadsheet), I get an error because the code is applied to the other
spreadsheet (not the one that the form is intended for).

I'm wondering what the best way is to get around this issue. I would just
hardcode in the name of the file for which the code is intended for only that
there are many different people that will use the spreadsheet and they can
save a different name to the file. What I tried to do was put the the
following formulas into the spreadsheet in order to get the name of the
spreadsheet and then use the code below to select the spreadsheet -- the
issue is that for some reason, the spreadsheet formulas sometimes show
"SOLVER" as the file name which is incorrect..then when I double click in the
cell, the correct name of the file shows again.

Spreadsheet formulas:

- cell BA1 formula: =CELL("filename")

- cell BB1 formula:
=IF(ISERROR(LEFT(BA1,SEARCH("]",BA1)-5)),LEFT(BA1,SEARCH(".",BA1)-1),LEFT(BA1,SEARCH("]",BA1)-5))

- cell BC1 formula:
=IF(ISERROR(RIGHT(BB1,LEN(BB1)-SEARCH("[",BB1))),BB1,RIGHT(BB1,LEN(BB1)-SEARCH("[",BB1)))

Code executed when "Proceed" button of form clicked ("strworkbname" is the
value within cell BC1):

Windows(strworkbname).Activate

--
Robert

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 144
Default Issue with workbook not being selected when form button is cli

That works!! Thank you so much!
--
Robert


"JMB" wrote:

if you want the code to run on the same workbook in which the form is
located, try using ThisWorkBook.Activate


"robs3131" wrote:

Hi all,

I have an issue where I have a form come up that requires the user to select
a checkbox and then select a "Proceed" button that results in code being
executed and then the form closing. The issue I have is that when the form
is opened, if I then click into another spreadsheet that I have open and then
click on say the "Proceed" button of the form (which applies to the other
spreadsheet), I get an error because the code is applied to the other
spreadsheet (not the one that the form is intended for).

I'm wondering what the best way is to get around this issue. I would just
hardcode in the name of the file for which the code is intended for only that
there are many different people that will use the spreadsheet and they can
save a different name to the file. What I tried to do was put the the
following formulas into the spreadsheet in order to get the name of the
spreadsheet and then use the code below to select the spreadsheet -- the
issue is that for some reason, the spreadsheet formulas sometimes show
"SOLVER" as the file name which is incorrect..then when I double click in the
cell, the correct name of the file shows again.

Spreadsheet formulas:

- cell BA1 formula: =CELL("filename")

- cell BB1 formula:
=IF(ISERROR(LEFT(BA1,SEARCH("]",BA1)-5)),LEFT(BA1,SEARCH(".",BA1)-1),LEFT(BA1,SEARCH("]",BA1)-5))

- cell BC1 formula:
=IF(ISERROR(RIGHT(BB1,LEN(BB1)-SEARCH("[",BB1))),BB1,RIGHT(BB1,LEN(BB1)-SEARCH("[",BB1)))

Code executed when "Proceed" button of form clicked ("strworkbname" is the
value within cell BC1):

Windows(strworkbname).Activate

--
Robert

  #4   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Issue with workbook not being selected when form button is cli

quite welcome, thanks for posting back

"robs3131" wrote:

That works!! Thank you so much!
--
Robert


"JMB" wrote:

if you want the code to run on the same workbook in which the form is
located, try using ThisWorkBook.Activate


"robs3131" wrote:

Hi all,

I have an issue where I have a form come up that requires the user to select
a checkbox and then select a "Proceed" button that results in code being
executed and then the form closing. The issue I have is that when the form
is opened, if I then click into another spreadsheet that I have open and then
click on say the "Proceed" button of the form (which applies to the other
spreadsheet), I get an error because the code is applied to the other
spreadsheet (not the one that the form is intended for).

I'm wondering what the best way is to get around this issue. I would just
hardcode in the name of the file for which the code is intended for only that
there are many different people that will use the spreadsheet and they can
save a different name to the file. What I tried to do was put the the
following formulas into the spreadsheet in order to get the name of the
spreadsheet and then use the code below to select the spreadsheet -- the
issue is that for some reason, the spreadsheet formulas sometimes show
"SOLVER" as the file name which is incorrect..then when I double click in the
cell, the correct name of the file shows again.

Spreadsheet formulas:

- cell BA1 formula: =CELL("filename")

- cell BB1 formula:
=IF(ISERROR(LEFT(BA1,SEARCH("]",BA1)-5)),LEFT(BA1,SEARCH(".",BA1)-1),LEFT(BA1,SEARCH("]",BA1)-5))

- cell BC1 formula:
=IF(ISERROR(RIGHT(BB1,LEN(BB1)-SEARCH("[",BB1))),BB1,RIGHT(BB1,LEN(BB1)-SEARCH("[",BB1)))

Code executed when "Proceed" button of form clicked ("strworkbname" is the
value within cell BC1):

Windows(strworkbname).Activate

--
Robert

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
New record button grayed out on auto form w/ shared workbook Jase4now Excel Discussion (Misc queries) 0 August 31st 07 10:56 PM
let a sub recognise the name of the button that has been clicked. Brotherwarren Excel Discussion (Misc queries) 2 March 18th 06 10:56 AM
Charts appear snowy (e.g., tv) unless clicked on. Memory issue? Vlookup help Charts and Charting in Excel 1 December 12th 05 09:17 PM
Do until button clicked kaiser Excel Programming 3 August 31st 05 12:41 PM
Pause macro, add form button to sheet, continue macro when button clicked! Flystar[_15_] Excel Programming 1 May 26th 04 09:45 AM


All times are GMT +1. The time now is 08:49 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"