ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Adding 1 (https://www.excelbanter.com/excel-programming/375383-adding-1-a.html)

Zaahir

Adding 1
 
Hi
here's the scenario.......
Default number = 06/0241 ....
i have a userform (US1) with a button (CMD1), upon executing CMD1 ColumnA
cellA1 in the worksheet must be selected and a number inserted i.e. 06/0241 +
1. thiss cell should now display 06/0242, upon 2nd execution of CMD cellA2
should display 06/0243 etc...
is this posible to be done usin code....
Please assist


WhytheQ

Adding 1
 
something like the below might work:

'=====================================
Private Sub CMD1_Click()

Dim myRow As Integer
myRow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row

If Range("A1") = "" Then
Range("A1") = "06/0242"
Else
Cells(myRow + 1, 1) = "06/024" & myRow + 2
End If

End Sub
=====================================

Rgds
J


On Oct 18, 1:46 pm, Zaahir wrote:
Hi
here's the scenario.......
Default number = 06/0241 ....
i have a userform (US1) with a button (CMD1), upon executing CMD1 ColumnA
cellA1 in the worksheet must be selected and a number inserted i.e. 06/0241 +
1. thiss cell should now display 06/0242, upon 2nd execution of CMD cellA2
should display 06/0243 etc...
is this posible to be done usin code....
Please assist



Stefi

Adding 1
 
Function incr2nd(celltoinc As Range)
parts = Split(celltoinc, "/")
incr2nd = parts(0) & "/" & Format(parts(1) + 1, "0000")
End Function

Sub test()
x = incr2nd(ActiveCell)
End Sub

Regards,
Stefi

Zaahir ezt *rta:

Hi
here's the scenario.......
Default number = 06/0241 ....
i have a userform (US1) with a button (CMD1), upon executing CMD1 ColumnA
cellA1 in the worksheet must be selected and a number inserted i.e. 06/0241 +
1. thiss cell should now display 06/0242, upon 2nd execution of CMD cellA2
should display 06/0243 etc...
is this posible to be done usin code....
Please assist



All times are GMT +1. The time now is 10:52 PM.

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