Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set a cell to hard coded text and a variable

Status
Not open for further replies.

mxp346

MIS
Apr 27, 2002
50
0
0
US
I am trying to use VBA in excel to have the next empty cell value to be a combination of hard coded text and a variable.

The code below is part of a loop that goes through each of the worksheet and sets the variable userid to cell A1. I then want the code to enter the following in the next blank cell: INSERT INTO MF_SCTY_PRNC(USERID) VALUES ("<userid variable>");


I need to figure out what to set the value to..

Sheets("Scripts").Range("A" & lRow + 1).Value =


I know that I could set the 1st column to the text and then set the second column to the value but I was wondering if could be done in one statement because I wanted to expand on what the statement above is doing.


Thanks for the help in advance.
Matt
 
Something like this ?
Sheets("Scripts").Range("A" & lRow + 1).Value = "INSERT INTO MF_SCTY_PRNC(USERID) VALUES ('" & userid & "');"


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thank you very much, that worked just like expected.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top