Assign Serial Number in Excel like 1,1,2,2,3,3, and so on

DHYADAV

New Member
Joined
Oct 28, 2018
Messages
2
Hi everyone.

[FONT=verdana, geneva, lucida, lucida grande, arial, helvetica, sans-serif]want to assign serial number in column A like 1,1,2,2,3,3 and like

[/FONT]using following vba code but asssign serial number like 1,2,3, and like


Sub FillSerialNumbers()
With Range("A3:A" & Range("B" & Rows.Count).End(xlUp).Row)
.Cells(1, 1).Value = 1
.DataSeries Rowcol:=xlColumns, Type:=xlLinear, Step:=1, Trend:=False
End With
End Sub




Any ideas? I'm sure it's a minor error but I'm really stumped!!

Thanks in advance,

Dharmesh
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Give this macro a try...
Code:
[table="width: 500"]
[tr]
	[td]Sub FillSerialNumbers()
  With Range("A1:A" & Range("B" & Rows.Count).End(xlUp).Row)
    .Value = Evaluate("IF({1},INT((1+ROW(" & .Address & "))/2))")
  End With
End Sub[/td]
[/tr]
[/table]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,271
Members
452,628
Latest member
dd2

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