I wonder whether someone may be able to help me please with a problem I have in using an auto incrementing number.
I'm using the code below to copy and paste data between worksheets.
This works fine, but if possible, what I'd like to do is where the code inserts the word 'Scheduled Site' I'd like it to add the number for which it appears in the list e.g. for the first row in the list to say 'Scheduled Site 1', then 'Scheduled Site 2' automatically calculating the next number until it reaches the end of the list.
I must admit this has proved to be beyond my capabilites. I just wondered whether somone could perhaps show me what I need to do to add the auto incrementing number.
Many thanks
I'm using the code below to copy and paste data between worksheets.
Code:
Sub CopyData()
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim rng1 As Range
Set ws1 = Sheets("Input")
Set ws2 = Sheets("Output")
On Error Resume Next
Set rng1 = ws1.Range(ws1.[b4], ws1.Cells(Rows.Count, "B").End(xlUp)).SpecialCells(xlConstants)
On Error GoTo 0
If rng1 Is Nothing Then Exit Sub
Application.ScreenUpdating = False
Set rng2 = ws2.[b2]
rng1.Copy
rng2.PasteSpecial xlPasteValues
'copy column I to Output C2
rng1.Offset(0, 7).Copy
rng2.Offset(0, 1).PasteSpecial xlPasteValues
'copy column N to Output d2
rng1.Offset(0, 12).Copy
rng2.Offset(0, 2).PasteSpecial xlPasteValues
rng2.Offset(0, 3).Resize(rng1.Cells.Count, 1) = "Scheduled Site"
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub
This works fine, but if possible, what I'd like to do is where the code inserts the word 'Scheduled Site' I'd like it to add the number for which it appears in the list e.g. for the first row in the list to say 'Scheduled Site 1', then 'Scheduled Site 2' automatically calculating the next number until it reaches the end of the list.
I must admit this has proved to be beyond my capabilites. I just wondered whether somone could perhaps show me what I need to do to add the auto incrementing number.
Many thanks