0

I am currently learning to code in excel VBA and I wrote the following code but when I run it, I get a runtime error 13 type mismatch. Any Ideas

Sub dennis()
Sheets(Sheet2).Select
Range("E1").Select

Do Until Selection.Offset(0, -4).Value = ""

Selection.Value = Selection.Offset(0, -4).Value & " " & Selection.Offset(0, -3).Value
Selection.Offset(1, 0).Select
Loop
Range("F1").Select
End Sub
Kᴀτᴢ
  • 2,146
  • 6
  • 29
  • 57
  • This is not an answer, but generally speaking, not good to rely on `Select`, see [here](http://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba-macros) for a good explanation. Cheers! – David Zemens Feb 10 '15 at 16:50

2 Answers2

1

Your sheet is not named correctly:

Change Sheets(Sheet2).Select to Sheets("Sheet2").Select

Kᴀτᴢ
  • 2,146
  • 6
  • 29
  • 57
0

The error is the argument of the property Sheet. The argument must be an index.

To select the sheet number 2, you can write Sheets(2).Select or Sheets("Sheet2").select

ele
  • 1