Insert same value for many rows, depends on number

NDMDRB

Board Regular
Joined
Jun 20, 2016
Messages
164
Office Version
  1. 2016
Platform
  1. Windows
Hello,

I have a userform that contains a lot of controls

One of them is "cmdSubmit" that contains many actions (I finished them all instead the following)

I already have piece of code that copy a range and paste it in sheet2 (this range contains (Name, ID, ...)(Doesn't contain the Number)
ex: I copied the range and pate it in sheet2 B4 (using the code below)

Code:
ws.Range("DailySales_SalesList").Copy
    With Sheet2.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0)
        .PasteSpecial xlPasteValues
        .PasteSpecial xlPasteFormats
        Application.CutCopyMode = False
    End With

What I missed is:

A piece of code to inset the Number in Column "A" Row (Depends on the name count)
A4, A5, A6 should be (Sheet3.Cells(Rows.Count, 1).End(xlUp).Value + 1) ex: 234

I tried the following code but I got an error

Code:
Set c = ws.Range("I:I").Find(What:=Me.txt_Name1.Value, LookIn:=xlValues)
a = Sheet2.Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To Application.WorksheetFunction.CountIf(ws.Range("I:I"), c)
a.Offset(i, 0) = Sheet3.Cells(Rows.Count, 1).End(xlUp).Value + 1
Next i



I need your help please and many thanks in advance


Sheet2
ABCD
1NumberName
2222Pop
3222Pop
4Adam
5Adam
6Adam

<tbody>
</tbody>

 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Forum statistics

Threads
1,214,978
Messages
6,122,549
Members
449,089
Latest member
davidcom

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