Home > Enterprise >  Select Range of cells based on Row Number on a different sheet
Select Range of cells based on Row Number on a different sheet

Time:10-01

I am completely lost. I am trying to use values from cells on a different sheet to establish the Starting Row and the Ending Row, in ColumnA of the Active Sheet.

I keep getting Compile Errors. Can someone help with the VBA format?

Dim s As String
s = "=Math!A3"
Range("=Math!C3", 1)("=Math!D3", 1) = s

Thanks

CodePudding user response:

Using some variables:

With ActiveWorkbook.Worksheets("Math")
    Dim startRow As Long
    startRow = .Range("C3").Value

    Dim endRow As Long
    endRow = .Range("D3").Value
End With

Dim s As String
s = "=Math!A3"

ActiveSheet.Range("A" & startRow & ":A" & endRow).Formula = s
  • Related