Add a prefix

C

CAM

Hi,


In column A I have a worksheet that can have rows from 2 to 200 or more
depending upon the workbook. Row 1 is headers. The data will be "SS_11" in
row 2 "SS_12" in row 3 etc. What I want to do is to have a command button
to slightly change the data to add a prefix depending upon what I have in
cell F2. for example cell F2 has "Dept" so in column A should be
"Dept_SS_11" in row 2 v"Dept_SS12" in row 3 etc. In another workbook I
may have "Corp" in cell F2 then I should see in column A "Corp_SS_11" in
row 2 "Corp_SS_12" in row 3 etc. How do I add the prefex based on the
contend on F2, again depending upon the workbook I may have 2 row or more.
Any tips or website to visit will be appreciated. Thank you in advance.

Cheers.
 
B

Bob Phillips

Just run a simple macro

Public Sub ProcessData()
Const TEST_COLUMN As String = "A" '<=== change to suit
Dim i As Long
Dim iLastRow As Long

With ActiveSheet

iLastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = 1 To iLastRow
.Cells(i, TEST_COLUMN).Value = .Range("F2").Value & _
.Cells(i, TEST_COLUMN).Value
Next i
End With

End Sub



--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
C

CAM

Thanks Bob. I will give a try.

Cheers

Bob Phillips said:
Just run a simple macro

Public Sub ProcessData()
Const TEST_COLUMN As String = "A" '<=== change to suit
Dim i As Long
Dim iLastRow As Long

With ActiveSheet

iLastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = 1 To iLastRow
.Cells(i, TEST_COLUMN).Value = .Range("F2").Value & _
.Cells(i, TEST_COLUMN).Value
Next i
End With

End Sub



--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top