ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Change number when you open the excel template (https://www.excelbanter.com/excel-discussion-misc-queries/51021-change-number-when-you-open-excel-template.html)

mowen

Change number when you open the excel template
 

Hi everebody

My intention is to make a template to my reports. To make order in all
my reports I want a macro that change the reports number every time I
open the template.
First time I open the template the reports number will be 1 (The string
in the workbook is Report number 1) and next time report number 2.....

I hope it is possible and that one of you excel members will help me
out!

Thank you and best regards
Rune


--
mowen
------------------------------------------------------------------------
mowen's Profile: http://www.excelforum.com/member.php...fo&userid=8463
View this thread: http://www.excelforum.com/showthread...hreadid=477206


swatsp0p

Change number when you open the excel template
 

try something like this in a Workbook Open() event:

Private Sub Workbook_Open()
Sheets("sheet1").Select
Range("A1").Value = Range("A1").Value + 1
Range("A1").Select

End Sub


--
swatsp0p


------------------------------------------------------------------------
swatsp0p's Profile: http://www.excelforum.com/member.php...o&userid=15101
View this thread: http://www.excelforum.com/showthread...hreadid=477206


mowen

Change number when you open the excel template
 

Hi swatsp0p

Thanks mate!


--
mowen
------------------------------------------------------------------------
mowen's Profile: http://www.excelforum.com/member.php...fo&userid=8463
View this thread: http://www.excelforum.com/showthread...hreadid=477206


mowen

Change number when you open the excel template
 

Hi again

I have discovered a problem when I saved the report with another name.
With this code it will also count everytime I open this file. It is
possible to restrict the macro to only be active at the template file
or other methods to avoid this problem?

best regards
Rune


--
mowen
------------------------------------------------------------------------
mowen's Profile: http://www.excelforum.com/member.php...fo&userid=8463
View this thread: http://www.excelforum.com/showthread...hreadid=477206



All times are GMT +1. The time now is 04:16 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com