Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > PC based Database Applications > Microsoft Excel > Copy Paste & Include other Data

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-12-08, 09:53
JezLisle JezLisle is offline
Registered User
 
Join Date: Apr 2007
Location: Stalybridge, Manchester
Posts: 240
Copy Paste & Include other Data

I bring back data from a SQL Server database, and want to find out how I can include a word after the data I import is pasted into a cell.

This is my Code I have to paste the data record.

Code:
Sheet3.Range("C12").ClearContents Set rsDW = New ADODB.Recordset sQRY = "SELECT MAX([Weeks Waiting]) AS MAX " & _ "FROM jez.CYPPhyPaediatric " rsDW.CursorLocation = adUseClient rsDW.Open sQRY, cnnDW, adOpenDynamic, adLockOptimistic, adCmdText Application.ScreenUpdating = False Sheet3.Range("C12").CopyFromRecordset rsDW rsDW.Close Set rsDW = Nothing

What I want to do is in Cell C12 once it pastes the Number add Weeks after, so would look like 7 Weeks

How is that possible?
Reply With Quote
  #2 (permalink)  
Old 09-12-08, 10:03
georgev georgev is offline
SQL Apprentice
 
Join Date: Jan 2007
Location: hiding
Posts: 8,131
This would work...
Code:
SELECT Convert(varchar, Max([Weeks Waiting])) + ' weeks' As [max]
Other options include concatenating the word within Excel ala
Code:
Sheet3.Range("C12").Value = Sheet3.Range("C12").Value & " weeks"
__________________
George
You only stop learning when you stop asking questions.
Reply With Quote
  #3 (permalink)  
Old 09-12-08, 11:11
JezLisle JezLisle is offline
Registered User
 
Join Date: Apr 2007
Location: Stalybridge, Manchester
Posts: 240
Excellent Thanks
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On