# Add Text infront of Numbers

#### bongyc

##### New Member
Dear all,

In Sheet 1, A2 to A100 contains a list of numbers. I would like to do the following by creating a VBA:

1) Copy A2 to A100 from Sheet 1 to Sheet 2 at A2 to A100;

2) Add a text "DL" infront of the numbers in Sheet 2 after the above copying.

Appreciate for your expertise. Thank you.

Cheers,
YC

### Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Do you really need VBA?
Code:
``````Sub CopyAddDL()

Worksheets("Sheet2").Range("A2").Formula = "=" & Chr(34) & "DL" & Chr(34) & "& Sheet1!A2"

Worksheets("Sheet2").Range("A2").Copy Worksheets("Sheet2").Range("A2:A100")

Worksheets("Sheet2").Range("A2:A100").Copy

Worksheets("Sheet2").Range("A2").PasteSpecial xlPasteValues

Application.CutCopyMode = False

End Sub``````

Code:
``````Sub CopyData()
Dim cell as range, ss as worksheet, ps as worksheet

set ss = activesheet
set ps = sheets("Sheet2")

for each cell in ss.range("A2:A100")
Next

End sub``````

HTH
Cal

On Sheet2, Cell: A2 add this formula:

="DL" & Sheet1!A2

Then copy this formula down to the bottom of your range on Sheet2!

Dear Joe, Cbrine and Norie,

Thank you very much with the brilliant solutions which really made my day.

Norie, may I know what is the reason for putting Chr(34) before and after DL in the VBA ?

Cheers,
YC

Chr(34) represents a double quote ", which is needed for the worksheet formula.

Dear Norie,

Thanks for the explanation. It helps me to understand better.

Replies
5
Views
149
Replies
6
Views
461
Replies
11
Views
464
Replies
7
Views
273
Replies
2
Views
322

1,216,299
Messages
6,129,969
Members
449,545
Latest member
SURY

### 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.

### Which adblocker are you using?

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

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