ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   queries in excel (https://www.excelbanter.com/excel-discussion-misc-queries/189638-queries-excel.html)

gaby elia

queries in excel
 
if we have a file in excel and there is a cell starting in number 1 and when
i want to close this sheet and reopen it again i wanna be 2 by auto ,so each
time i open this file i wanna this number to be increased automatically


Kevin B

queries in excel
 
Press Alt + F11 to open the VBE and then double click the ThisWorkbook object
in the project window.

In the Code pane change the value in the combo box on the left to Workbook
and the value in the combobox on the right to Open.

Enter the following line of code in the Workbook_Open() event


Sheets(1).Range("A1").Value = Sheets(1).Range("A1").Value + 1

Change the worksheet's index number to the reference the sheet you're
wanting to track the number of times the workbook is opened and the cell
address you want the total in. Sheets can also be referenced by their tab
name as follows.

Sheets("Sheet1").Range("A1").Value = Sheets("Sheet1").Range("A1").Value
+ 1



--
Kevin Backmann


"gaby elia" wrote:

if we have a file in excel and there is a cell starting in number 1 and when
i want to close this sheet and reopen it again i wanna be 2 by auto ,so each
time i open this file i wanna this number to be increased automatically


Gary''s Student

queries in excel
 
This will increment cell A1 in worksheet Sheet1:

Private Sub Workbook_Open()
With Sheets("Sheet1").Range("A1")
.Value = .Value + 1
End With
End Sub

This event macro goes in the workbook code area.
--
Gary''s Student - gsnu200789


"gaby elia" wrote:

if we have a file in excel and there is a cell starting in number 1 and when
i want to close this sheet and reopen it again i wanna be 2 by auto ,so each
time i open this file i wanna this number to be increased automatically



All times are GMT +1. The time now is 08:48 PM.

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