Simple add on to macro?

ppleasebob

Board Regular
Joined
Dec 23, 2002
Messages
145
I have used the following code, as provided on this board for someone else,

Sub Job_Number()

Dim Startcell As Range

' The fist job number cell
Set Startcell = Range("A10")

If IsEmpty(Startcell) Then
' First Job number
Startcell = 1
Else
' Next job number
With Cells(Rows.Count, Startcell.Column).End(xlUp)
.Offset(1).Value = .Value + 1

End With
End If

End Sub

Can you suggest how I then copy the number that was generated above and paste it into Cell D5 on sheet named "Main"


Thanks for your assistance in advance

bob
 

Some videos you may like

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

John Davis

Well-known Member
Joined
Sep 11, 2007
Messages
3,457
I have used the following code, as provided on this board for someone else,

Sub Job_Number()

Dim Startcell As Range

' The fist job number cell
Set Startcell = Range("A10")

If IsEmpty(Startcell) Then
' First Job number
Startcell = 1
Else
' Next job number
With Cells(Rows.Count, Startcell.Column).End(xlUp)
.Offset(1).Value = .Value + 1

End With
End If

End Sub

Can you suggest how I then copy the number that was generated above and paste it into Cell D5 on sheet named "Main"


Thanks for your assistance in advance

bob

Maybe this line after End if:

Sheets("Main").Range("D5").Value = ActiveSheet.Cells(Rows.Count, Startcell.Column).End(xlUp).Offset(1).Value + 1
 

ppleasebob

Board Regular
Joined
Dec 23, 2002
Messages
145
John,

Thanks for this however it doesn't quite do it, the second time you run the macro, it still returns the value of 1 rather than 2

Any ideas?
 

Watch MrExcel Video

Forum statistics

Threads
1,122,694
Messages
5,597,571
Members
414,156
Latest member
WDMix

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top