Angro
Angro

Reputation: 9

Select specified cell

In Outlook 2010 I have VBA code to put the selection to A1 and then save the Excel workbook.

With wbFm.Sheets(1)
.................
  LastrOn = .Cells(.Rows.Count, "AQ").End(xlUp).Row

  For i = 6 To LastrOn
  Val = .Cells(i, 43).Value

  Set FoundCell = .Columns("A").Find(Val)

    If Not FoundCell Is Nothing Then

    .Cells(i, 44).Copy
    .Cells(FoundCell.Row, 14).PasteSpecial xlPasteValues    <---- last cell picked up
    end if
        
     .................................
   Next
 .Range("AQ4") = "text1"
 .Range("AU4") = "tekst2"
End With

wbFm.Application.Goto wbFm.Sheets(1).Range("A1"),True

Fdest = emailfolder & Filedest & RepDate & ".xlsx"

If fsob.fileexists(Fdest) = False Then
    wbFm.SaveAs Fdest
End If
........

wbFm is the open workbook.

After upgrade to Outlook 2013 this command is not working any more.

wbFm.Application.Goto wbFm.Sheets(1).Range("A1"),True

When I delete this command, the program finishes properly, but the cursor when I open the saved file is on the last picked cell.

Upvotes: 0

Views: 347

Answers (1)

Nathan Dudley
Nathan Dudley

Reputation: 582

Assuming wbFm is an Excel workbook object, you can simply select the cell. No need for the GoTo statement.

wbFm.Sheets(1).Range("A1").Select

Upvotes: 1

Related Questions