Results 1 to 4 of 4
  1. #1
    RunTime91 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    260

    Adding a Cell Range to a String Variable

    Hello...



    I am trying to add a range to the end of this DoCmd statement and you'd think it would be easy...not a chance for a newb as me..

    yes, I have tried every possible combination I can think of and well, here I am.

    As I'm sure you can tell, I'm simply trying to add the range to the strWorksheet variable

    Code:
     StrWorksheet = "Sales Grand Total Summary"
            DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12, "TempSalesMTD", StrNewFileName, True, StrWorksheet & .Range("A4:K4")
    Thanks for any help...

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    50,038
    Did you try: & "!A4:K4"

    Works for me.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    RunTime91 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    260
    Quote Originally Posted by June7 View Post
    Did you try: & "!A4:K4"

    Works for me.
    Ran all around that one! Works a treat!!

    Good to hear from you again June

    Quick question, in this solution what does the ! do? I was using one but not like that

    Thanks again, June...

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    50,038
    It's always been the syntax for directly referencing a sheet name and range. Otherwise, using Range property would be like:


    Worksheets("Sales Grand Total Summary").Range("A1:K4")


    Not really what you want.


    Since the range starts with A1, probably don't even need to include the range.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Clear Cell Range Based on Text in Another Cell
    By Oxygen Potassium in forum Access
    Replies: 3
    Last Post: 08-20-2017, 08:12 PM
  2. Adding textbox.text to a string variable...
    By MatthewGrace in forum Programming
    Replies: 2
    Last Post: 05-20-2014, 11:43 AM
  3. Replies: 6
    Last Post: 09-10-2013, 08:37 AM
  4. Replies: 4
    Last Post: 06-18-2013, 08:50 PM
  5. Replies: 3
    Last Post: 05-28-2013, 12:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums - Senior Forums