Concanate problem

PANKAJUTEKAR

Board Regular
Joined
Jun 10, 2011
Messages
79
All Experts,
Hi..

j = col B

Function concatenate()
Dim i As Integer, j As Integer
Do Until j = 18
i = 2.................rowindex
j = 3.................colindex
Cells(i, j) = Cells(3, 2)........range("b3")
ActiveCell.FormulaR1C1 = "=concatenate(""P-"",cell(3,2))"
j = j + 1
Loop
End Function

Private Sub Workbook_Open()
Call concatenate
End Sub

Wht i tryed, in my col A is blank.
col b contains some tags like -
01H001A-M01
01H001A-M02
01H001A-M03 and more.

i got an error 1004...for -
ActiveCell.FormulaR1C1 = "=concatenate(""P-"",cell(3,2))"

So, how do i concatenate P- with respective cells automatically?
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Hi

Try:

Code:
ActiveCell.FormulaR1C1 = "=concatenate(""P-"",R" & i & "C" & j & ")"
 
Upvote 0
First, you're using FormulaR1C1 when you use A1 notation.
Second, not "cell", but "Cells".
Third, "cells" must be concatenated with ampersand (&).
Code:
ActiveCell = "P-" & Cells(3, 2)
 
Upvote 0
So if you want to keep the cell reference then

Range("A3").Formula = "=Concatenate(""P-""," & Cells(3, 2).Address & ")"

else use SEKTOR's answer
 
Upvote 0
Dear All Experts,

Thanks For ur quick help.

i got 3 options (answers) from you. All are working but only for the one cell that b3.
my row index not going increasing wherein,
i put j=j+1

You got it all?


Kind Suggestion..
 
Upvote 0
In your code ActiveCell doesn't advance. Is in red what you want?
Code:
[COLOR="Blue"]Sub[/COLOR] concatenate()
 
    [COLOR="Blue"]Dim[/COLOR] j [COLOR="Blue"]As[/COLOR] [COLOR="Blue"]Integer[/COLOR]
    
    j = 1
    [COLOR="Blue"]Do[/COLOR] Until j = 18
        ActiveCell = "P-" & cell(2, j)
        j = j + 1
[B][COLOR="Red"]        ActiveCell = ActiveCell.Offset(1, 0)[/COLOR][/B]
    [COLOR="Blue"]Loop[/COLOR]
    
[COLOR="Blue"]End[/COLOR] [COLOR="Blue"]Sub[/COLOR]
 
Last edited:
Upvote 0
You update the same cell 18 times. Is it OK?
 
Upvote 0

Forum statistics

Threads
1,224,516
Messages
6,179,231
Members
452,898
Latest member
Capolavoro009

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