ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Autofill of single cells (https://www.excelbanter.com/excel-discussion-misc-queries/206989-autofill-single-cells.html)

dannie

Autofill of single cells
 
I have a workbook that is read only and needs to have 1 cell autofilled in
with the next ascending number everytime we access the workbook.

Sheeloo[_3_]

Autofill of single cells
 
Use this
Private Sub Workbook_Open()
If Sheets("Sheet3").Cells(1, 1) < 0 Then
Sheets("Sheet3").Cells(1, 1).Value = Sheets("Sheet3").Cells(1, 1).Value + 1
Else
Sheets("Sheet3").Cells(1, 1).Value = 1
End If
End Sub

To enter this code
Open your workbook
Press ALT-F11 to open VBE
Click on This Workbook under your workbookname
Paste the above macro
Save your workbook, close and open it.
This will increment the no. in A1 of sheet3...
--
Always provide your feedback so that others know whether the solution worked
or problem still persists ...


"Dannie" wrote:

I have a workbook that is read only and needs to have 1 cell autofilled in
with the next ascending number everytime we access the workbook.


ShaneDevenshire

Autofill of single cells
 
Hi,

I think you need code like this:

Private Sub Workbook_Open()
Dim x As Long
x = Sheets("Sheet1").Range("A1")
Sheets("Sheet1").Range("A1") = x + 1
End Sub

--
Thanks,
Shane Devenshire


"Dannie" wrote:

I have a workbook that is read only and needs to have 1 cell autofilled in
with the next ascending number everytime we access the workbook.



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

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