copy and paste code

dennisli

Well-known Member
Joined
Feb 20, 2004
Messages
1,070
Good afternoon, everyone
I have a customer ID list in numerical format such as 678456 from Sheet1!B8:B150 and I want to copy and paste to Sheet2 from range A26 by 10 steps. For example, Sheet1!B8 to Sheet2!A26, Sheet1!B9 to Sheet2!A36, Sheet1!b10 to Sheet2!A46, etc. But for each customer ID in Sheet2, I want to put sign of Customer ID before the 678456 to become: Customer ID 678456.
Thanks lot.
Dennis
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Dennis,

Try the following macro:

Code:
Public Sub CopyCustomerIDs()
Dim i   As Long, _
    ws1 As Worksheet, _
    ws2 As Worksheet, _
    LR  As Long
    
With Application
    .ScreenUpdating = False
    .Calculation = xlCalculationManual
End With
Set ws1 = Sheets("Sheet1")
Set ws2 = Sheets("Sheet2")
LR = ws1.Range("B" & Rows.Count).End(xlUp).Row
For i = 8 To LR
    ws2.Range("A" & 26 + ((8 - i) * 10)).Value = "Customer ID " & ws1.Range("B" & i).Value
Next i
With Application
    .ScreenUpdating = True
    .Calculation = xlCalculationAutomatic
End With
End Sub
 
Upvote 0
untested:
Code:
Sub blah()
DestRow = 26    'starting value
For Each cll In Sheets("Sheet1").Range("B8:B150")
    Sheets("Sheet2").Range("A" & DestRow).Value = "Customer ID " & cll.Value
    DestRow = DestRow + 10
Next cll
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,733
Members
452,939
Latest member
WCrawford

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