ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Newbie (https://www.excelbanter.com/excel-programming/332573-newbie.html)

kenworld

Newbie
 

Anyone,

I'm trying to create a macro to automatic a tedious task. I need help
with a macro to concentatenate a string.

For example, I have a list of usercodes:

Column
A

nx109
px205
px206
qx123

I want to add the usercodes to a string that reads like this.

sp_addexternlogin SQL_PROD, wr_",nx109,", trust_user , trustuser"
go
sp_addexternlogin SQL_PROD, wr_",px205,", trust_user , trustuser"
go
sp_addexternlogin SQL_PROD, wr_",px206,", trust_user , trustuser"
go
sp_addexternlogin SQL_PROD, wr_",qx123,", trust_user , trustuser"
go

Please Help
Kenworld


--
kenworld
------------------------------------------------------------------------
kenworld's Profile: http://www.excelforum.com/member.php...o&userid=24543
View this thread: http://www.excelforum.com/showthread...hreadid=381377


Bob Phillips[_6_]

Newbie
 

Dim iLastRow As Long
Dim i As Long
Dim sTemp As String

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To iLastRow
sTemp = sTemp & "sp_addexternlogin ""," & Cells(i, "A").Value & _
",""," & " trust_user , trustuser" & vbNewLine & _
"go" & vbNewLine
Next i
MsgBox sTemp


--

HTH

RP
(remove nothere from the email address if mailing direct)


"kenworld" wrote in
message ...

Anyone,

I'm trying to create a macro to automatic a tedious task. I need help
with a macro to concentatenate a string.

For example, I have a list of usercodes:

Column
A

nx109
px205
px206
qx123

I want to add the usercodes to a string that reads like this.

sp_addexternlogin SQL_PROD, wr_",nx109,", trust_user , trustuser"
go
sp_addexternlogin SQL_PROD, wr_",px205,", trust_user , trustuser"
go
sp_addexternlogin SQL_PROD, wr_",px206,", trust_user , trustuser"
go
sp_addexternlogin SQL_PROD, wr_",qx123,", trust_user , trustuser"
go

Please Help
Kenworld


--
kenworld
------------------------------------------------------------------------
kenworld's Profile:

http://www.excelforum.com/member.php...o&userid=24543
View this thread: http://www.excelforum.com/showthread...hreadid=381377




kenworld[_2_]

Newbie
 

Thanks for your response, I'll give this a shot.

Kenworl

--
kenworl
-----------------------------------------------------------------------
kenworld's Profile: http://www.excelforum.com/member.php...fo&userid=2454
View this thread: http://www.excelforum.com/showthread.php?threadid=38137



All times are GMT +1. The time now is 11:44 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com