Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2007
    Location
    Stalybridge, Manchester
    Posts
    273

    Unanswered: 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?

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    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
    Home | Blog

  3. #3
    Join Date
    Apr 2007
    Location
    Stalybridge, Manchester
    Posts
    273
    Excellent Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •