Help with VBA code update

Status
Not open for further replies.

Lukma

Board Regular
Joined
Feb 12, 2020
Messages
240
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
Hi Guys

Can someone help to update this code which i found but i don't no how to include the Auto Serial number code along with the code
after inserting the code it works fine but i need the column B to general Serial Numbers but i guess i cant

Appreciate if anyone could assist

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim rInt As Range
    Dim rCell As Range
    Dim tCell As Range

    Set rInt = Intersect(Target, Range("B:B"))
    If Not rInt Is Nothing Then
        For Each rCell In rInt
            Set tCell = rCell.Offset(0, -1)
            If IsEmpty(tCell) Then
                tCell = Now
                tCell.NumberFormat = "mmm d, yyyy hh:mm"
            End If
        Next
    End If
End Sub
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
try this:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim rInt As Range
    Dim rCell As Range
    Dim tCell As Range
    rowno = Target.Row
    Set rInt = Intersect(Target, Range("B:B"))
    If Not rInt Is Nothing Then
        For Each rCell In rInt
            Set tCell = rCell.Offset(0, -1)
            If IsEmpty(tCell) Then
                Application.EnableEvents = False ' turn off events because we are writing into column B and stop triggering this sub twice
                tCell = Now
                tCell.NumberFormat = "mmm d, yyyy hh:mm"
                rowno = Target.Row
                mx = Application.WorksheetFunction.Max(Range(Cells(1, 2), Cells(rowno, 2)))
                rCell = mx + 1
                Application.EnableEvents = True
            End If
        Next
    End If
End Sub
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,214,829
Messages
6,121,827
Members
449,051
Latest member
excelquestion515

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
Back
Top