Results 1 to 2 of 2

Thread: MID Function

  1. #1
    2 Star Lounger
    Join Date
    Apr 2004
    Location
    Jacksonville, Florida, USA
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Arrow

    I have a workbook into which I'm importing a database report. I import it into Excel on a spreadsheet (Temp), then copy/paste some of the information to another spreadsheet (Data) in the workbook. One of the items I have to move gets treated as a MID string when it's on the Data spreadsheet, but I'm having trouble referencing it. My code is as follows:

    Sheets ("Temp").Select
    Application.CutCopyMode=False
    Range("A2").Select
    Selection.Copy
    Sheets("Data").Select
    ActiveCell.Offset(0,-1).Select
    ActiveSheet.Paste
    Application.CutCopyMode=False
    ActiveCell.FormulaR1C1="=MID("Temp!"$A$2,13,11)"
    ActiveCell.Select

    I'm getting an error on the ActiveCell.FormulaR1C1 line due to a bad reference to the Temp spreadsheet.

    All help will be appreciated. Thanks.

  2. #2
    5 Star Lounger
    Join Date
    Aug 2004
    Location
    Connecticut, USA
    Posts
    816
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Since you are using R1C1 referencing this line:
    ActiveCell.FormulaR1C1="=MID(Temp!$A$2,13,11)"

    should be:
    ActiveCell.FormulaR1C1="=MID(Temp!R2C1,13,11)"


    Or if you don't want to use R1C1 use:
    ActiveCell.Formula="=MID(Temp!$A$2,13,11)"


    Also, you need to remove the quotes from around the worksheet name Temp.

Posting Permissions

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