Could anyone tell me why when I refer to a particular range it works fine:
ActiveSheet.Range("A1:D3").Select
but
ActiveSheet.Range(Cells(1, 1), Cells(3, 4)).Select
not working?
Could anyone tell me why when I refer to a particular range it works fine:
ActiveSheet.Range("A1:D3").Select
but
ActiveSheet.Range(Cells(1, 1), Cells(3, 4)).Select
not working?
I suspect your code is in the worksheet code module of a different sheet, so the unqualified Cells
calls refer to that sheet, not the active one. You should always qualify all Range
or Cells
calls with a Worksheet
object:
ActiveSheet.Range(ActiveSheet.Cells(1, 1), ActiveSheet.Cells(3, 4)).Select
This also works avoiding the need to repeat several times the target worksheet: (see https://msdn.microsoft.com/EN-US/library/office/gg264723.aspx)
With ActiveSheet
.Range(.Cells(1, 1), .Cells(3, 4)).Select
End With