Re: Generate cells with values from other cells
This is perfect. I made a minor change so the S/N's starts in C2.
I set it so the cursor moves from A1 to B1 and back to A1 on change, froze the top line and gave C1 a header of Serial Number and added a button to run the macro.
Still wish the macro would run when cell B1 was changed. Oh well. Can't have everything.
Thank you so very much for the help.
VBA to add Serial Numbers
Sub SerialNumbers()
Dim startNum As Double
Dim numLoops As Long, c As Long, nextRow As Long
nextRow = Cells(Rows.Count, "C").End(xlUp).Row + 1
If nextRow = 2 Then nextRow = 2
startNum = Range("A1").Value
numLoops = Range("B1").Value - startNum
Application.ScreenUpdating = False
For c = 0 To numLoops
Cells(nextRow + c, "C").Value = c + startNum
Next c
Application.ScreenUpdating = True
End Sub
VBA to move from A1 to B1 and back if there are any changes.
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo Whoa
Application.EnableEvents = False
If Not Target.Cells.CountLarge > 1 Then
If Not Intersect(Target, Columns(1)) Is Nothing Then
Target.Offset(, 1).Select
ElseIf Not Intersect(Target, Columns(2)) Is Nothing Then
Target.Offset(-0, -1).Select
End If
End If
Letscontinue:
Application.EnableEvents = True
Exit Sub
Whoa:
MsgBox Err.Description
Resume Letscontinue
End Sub